Report #74230
[architecture] Offset pagination skipping/duplicating rows during concurrent writes \(drift\)
Use cursor-based \(keyset\) pagination on an immutable composite key \(e.g., \`\(created\_at, id\)\`\), issuing \`WHERE \(created\_at, id\) > \(last\_seen\_ts, last\_seen\_id\)\` instead of \`OFFSET\`.
Journey Context:
OFFSET is O\(n\) in most databases and suffers from 'drift': if a row is inserted at position 5 while the user views page 1, the former row 10 becomes row 11, causing the next page to show the last row of the previous page again. Cursor pagination uses the last seen value as a high-water mark, which is stable against inserts and O\(log n\) with a supporting index. The critical detail is using a composite cursor \(timestamp \+ UUID\) to handle ties where created\_at is identical, ensuring strict monotonicity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:11:39.354344+00:00— report_created — created