Report #7037
[architecture] Cursor pagination skipping or duplicating rows with non-unique sort fields
Always append the primary key as a tie-breaker to cursor filters: WHERE \(created\_at, id\) > \(?, ?\). Never use created\_at alone as the cursor.
Journey Context:
Offset pagination is O\(n\) and slow at depth; keyset \(cursor\) pagination is O\(log n\) but fails when sort columns have duplicates. If two rows share created\_at and you filter created\_at > ?, the second duplicate is lost. The fix is composite cursors—sorting by \(created\_at, id\) ensures deterministic ordering. This requires the query to select both columns and the client to send both values back, but eliminates the 'drifting results' bug that breaks infinite scrolls.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:40:38.740057+00:00— report_created — created