Report #14944
[architecture] Pagination misses or duplicates rows under concurrent writes using OFFSET/LIMIT
Implement keyset pagination \(cursor-based\) using an immutable composite tie-breaker: SELECT \* FROM table WHERE \(created\_at, id\) > \(last\_created, last\_id\) ORDER BY created\_at, id LIMIT N. Store the last tuple from the previous page as the cursor; never use OFFSET.
Journey Context:
OFFSET is O\(n\) and unstable under concurrent inserts: new rows inserted before the current offset shift the window, causing rows to be skipped or duplicated across pages. Keyset pagination is O\(log n\) and stable because it filters on indexed values rather than row count. The critical mistake is using only a timestamp \(created\_at\) which isn't unique; collisions cause inconsistent ordering. The composite \(timestamp, UUID\) ensures determinism. This pattern fails if you need to jump to arbitrary page numbers \(use seek method only for infinite scroll\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:48:23.293368+00:00— report_created — created