Report #69273
[architecture] Pagination drifting \(duplicate/missing items\) when data updates during offset browsing
Use cursor-based \(keyset\) pagination: WHERE \(created\_at, id\) > \(last\_seen\_timestamp, last\_seen\_id\) ORDER BY created\_at ASC, id ASC LIMIT page\_size. Store the last cursor \(timestamp\+id tuple\) from the current page to fetch the next page. Never expose OFFSET to users for real-time feeds.
Journey Context:
OFFSET pagination is O\(n\) cost \(database must scan and discard N rows\) and suffers from drift: if new items are inserted at the top while user is on page 1, shifting items down, then page 2 will show duplicates of items that moved from page 2 to page 1. Cursor pagination is O\(log n\) using index seeks and is stable against inserts \(new items appear at the end or beginning depending on sort, but no items are skipped/duplicated in the middle\). Requirements: cursor columns must be immutable \(or at least monotonic\) and unique composite key. UUIDv7 or KSUID are better than auto-increment for distributed systems. Tradeoff: can't jump to arbitrary page number \(no 'go to page 5'\), only next/previous. This is acceptable for feeds, unacceptable for admin data tables requiring random access.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:45:35.111906+00:00— report_created — created