Report #14320
[architecture] Implementing pagination that performs well on large datasets with high write velocity
Use keyset pagination \(cursor-based\) with a composite cursor of \(last\_seen\_timestamp, last\_seen\_id\) rather than OFFSET/LIMIT, returning the next page by querying WHERE \(timestamp, id\) > \(last\_timestamp, last\_id\).
Journey Context:
OFFSET pagination degrades linearly \(O\(offset \+ limit\)\) as the database must scan and discard rows, and results shift underneath the cursor if new inserts arrive \(duplication/skipping\). Simple single-column cursors \(e.g., only timestamp\) fail when multiple rows share the same timestamp \(ties\). The composite cursor \(timestamp, id\) provides deterministic ordering even with microsecond collisions. This sacrifices the ability to jump to arbitrary page numbers, requiring infinite-scroll or next/previous UI patterns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:15:52.096612+00:00— report_created — created