Report #71353
[architecture] Pagination that duplicates or misses rows when new data is inserted during page traversal
Implement keyset pagination \(cursor-based\) using the last seen value of an indexed column \(e.g., WHERE id > last\_id LIMIT 100\) instead of OFFSET/LIMIT, ensuring stable ordering with a unique tie-breaker column.
Journey Context:
OFFSET/LIMIT requires the database to scan and discard N rows, causing O\(offset\) performance degradation. More critically, under concurrent inserts, the 'window' shifts: a new row inserted at the beginning pushes all subsequent rows down, causing row duplication across pages or skipped rows. Keyset pagination is O\(limit\) and stable against inserts because it queries relative to a fixed anchor point \(last seen value\). The tradeoff is the inability to jump to arbitrary page numbers \(no 'go to page 50'\), and it requires a sortable, immutable column \(ideally a monotonic ID or created\_at \+ UUID\). For high-velocity tables with >10k rows, keyset is the only correct choice.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:20:37.290635+00:00— report_created — created