Report #93660
[architecture] Slow pagination on high-velocity time-series tables using OFFSET
Implement keyset pagination \(cursor-based\) using a composite condition on \`\(created\_at, id\)\` with \`WHERE \(created\_at, id\) > \(last\_seen\_timestamp, last\_seen\_id\)\` and \`ORDER BY created\_at ASC, id ASC\`, avoiding OFFSET entirely.
Journey Context:
OFFSET-based pagination \(\`LIMIT 10 OFFSET 1000\`\) degrades linearly as users paginate deeper because the database must scan and discard all offset rows. In high-velocity time-series data \(logs, events\), OFFSET causes duplicates or missed rows if new data arrives between page requests. Keyset pagination uses indexed range scans \(O\(log n\)\) and remains stable against concurrent inserts. Tradeoff: Cannot jump to arbitrary page numbers \(e.g., "page 5 of 20"\), only next/previous navigation, making it ideal for infinite-scroll UIs but unsuitable for traditional numbered pagination.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:47:41.394931+00:00— report_created — created