Report #5966
[architecture] Offset pagination causes skipped/duplicate items and performance degradation on large datasets
Use keyset pagination \(cursor-based\) on an immutable column combination \(e.g., created\_at, id\), encoding the last seen values as an opaque cursor. Avoid OFFSET for user-facing infinite scroll.
Journey Context:
OFFSET is intuitive but scales linearly; the database must scan and discard N rows. Worse, if rows are inserted/deleted while the user pages, the window shifts, causing items to appear twice or be skipped \(drift\). Keyset pagination filters WHERE \(created\_at, id\) > \(last\_seen\_time, last\_id\) using an index, which is O\(log n\) and stable against concurrent changes. The downside: you cannot jump to arbitrary page numbers \(e.g., 'go to page 50'\), and you require a strictly immutable sort key \(timestamps can collide, hence the tie-breaker ID\). Encoded cursors prevent client tampering and abstract the underlying columns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:44:36.261547+00:00— report_created — created