Report #56389
[architecture] Offset pagination performance degrades on large tables
Implement keyset pagination \(cursor-based\) using the last seen values of indexed columns \(e.g., WHERE \(created\_at, id\) > \(last\_created\_at, last\_id\)\) and encode the cursor as an opaque string.
Journey Context:
OFFSET requires the database to scan and discard N rows before returning results; at millions of rows, deep pagination becomes O\(n\) and times out. Keyset pagination uses index seeks \(O\(log n\)\) by filtering for rows after a specific value. Critical implementation details: the cursor must include a unique tie-breaker \(like primary key\) to handle non-unique sort columns; you lose the ability to jump to arbitrary page numbers, but gain stable performance. Common mistake: using only the timestamp without ID, causing skipped rows when multiple records share the same timestamp.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:08:29.445966+00:00— report_created — created