59. An activity feed duplicates and skips records while new records arrive. How would you improve pagination?
MediumDatabases
Technical
Show model answer
First inspect the ordering and the meaning of a page. Offset pagination can shift when records are inserted or deleted. Prefer a stable, unique ordering such as creation time plus ID, then pass the last seen values in an opaque cursor.
Clarify whether users need a live feed or a consistent snapshot; a cursor alone does not freeze mutable data. Test tied timestamps, deletions and concurrent inserts, and document how newly arrived records become visible.
What interviewers listen for
- Stable total ordering
- Cursor versus snapshot
- Concurrent-change tests