Report #15916
[architecture] Offset pagination skipping or duplicating rows during concurrent writes
Implement keyset pagination \(cursor-based\) using an immutable composite key \(e.g., \`\(created\_at, id\)\`\). Encode the last seen tuple as the cursor; query with \`WHERE \(created\_at, id\) > \(last\_created\_at, last\_id\)\`. Never use OFFSET for user-facing feeds.
Journey Context:
OFFSET-based pagination is simple but fundamentally flawed for concurrent environments: inserting a new row at the top shifts the window, causing users to skip items or see duplicates when navigating pages. Cursor pagination is stateless and consistent, but requires a stable, monotonic sort key. Timestamps alone are insufficient \(collisions\); composite cursors \(timestamp \+ UUID/id\) are necessary. The tradeoff: you cannot jump to arbitrary page numbers \(e.g., 'go to page 50'\), which is usually acceptable for feeds but not for admin dashboards.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:21:28.479614+00:00— report_created — created