Intermediate
Open
Pro
Why Offset Pagination Breaks a Live Feed
A junior engineer implements feed pagination as
GET /v1/feed?page=2&limit=20, which runs
SELECT ... ORDER BY created_at DESC LIMIT 20 OFFSET 20 against the
feed cache. Users report seeing the same post twice across pages, and
occasionally missing posts entirely between page loads.
- Explain precisely why offset pagination produces both symptoms on a feed that is being written to concurrently.
- Design a cursor-based replacement: what does the cursor encode, and how does the query change?
- Does cursor-based pagination fully solve the "new posts appearing between page loads" problem for a chronological feed? What additional client-side handling, if any, is still needed?
Share this question