Report #71615
[architecture] Duplicate or missing rows in paginated feeds under high write concurrency using OFFSET/LIMIT
Implement keyset pagination \(cursor-based\) on an immutable composite key \(e.g., \(created\_at, id\)\) instead of OFFSET; return opaque cursors to clients, not page numbers.
Journey Context:
OFFSET/LIMIT requires the database to scan and discard N rows for each page; as N grows, latency degrades linearly. Worse, concurrent inserts at the top of the sort order shift the window, causing items to appear twice \(if inserted above current offset\) or be skipped \(if deleted\). Keyset pagination uses WHERE \(created\_at, id\) > \(last\_seen\) leveraging an index for constant-time lookups regardless of depth. Tradeoffs: You cannot jump to arbitrary page numbers \(breaks 'go to page 50' UIs\), and you require a strictly monotonic sort key \(no NULLs, stable ordering\). For APIs serving mobile infinite scroll, this is the only scalable pattern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:46:46.909364+00:00— report_created — created