Report #9433
[architecture] Offset pagination returns duplicates or skips records under concurrent writes
Use keyset pagination with a composite cursor \(created\_at, id\) over a strictly monotonic ordering column; never use OFFSET for user-facing lists.
Journey Context:
OFFSET is O\(n\) and unstable: concurrent inserts cause items to shift between pages, creating duplicates or skips. Keyset \(cursor\) pagination is O\(log n\) and stable. The trap: using a single-column cursor like timestamp fails with millisecond collision \(two rows same timestamp\), requiring a tie-breaker \(id\). Also, DESC vs ASC must match the index direction exactly or the planner falls back to sorting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:12:23.717401+00:00— report_created — created