Report #8740
[architecture] Slow OFFSET pagination on large tables \(page 10000\+ takes seconds\)
Implement keyset pagination \(seek method\): instead of OFFSET, filter for rows where the sort key is greater than the last seen value \(e.g., WHERE id > last\_id ORDER BY id LIMIT 100\).
Journey Context:
OFFSET scans and discards N rows, causing linear cost growth with page depth \(O\(n\) per page\). Keyset pagination uses index seeks \(O\(log n\)\) regardless of depth. This requires an immutable, unique column \(usually PK\) and loses the ability to jump to arbitrary page numbers \(only next/prev\). For composite sorting \(date, id\), encode tuple comparison \(date, id\) > \(last\_date, last\_id\). Tradeoffs: cannot show 'Page 47 of 100' UI, requires stable sort order, and backfilling gaps is harder.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T06:18:20.167012+00:00— report_created — created