Report #15308
[architecture] Cursor pagination returning duplicate rows or missing data with UUID primary keys
Implement composite keyset pagination using \`\(created\_at, id\)\` as the cursor, ensuring strict inequality \`>\` \(not \`>=\`\) and deterministic \`ORDER BY created\_at ASC, id ASC\` to handle ties.
Journey Context:
UUIDs have no inherent time ordering. If two rows share a \`created\_at\` timestamp \(common with bulk inserts\), a single-column cursor on \`created\_at\` becomes non-deterministic, causing rows to be skipped or duplicated across pages. Using \`>= last\_seen\_timestamp\` with \`LIMIT\` causes off-by-one errors where the last row of page N becomes the first row of page N\+1 under concurrent inserts. The composite cursor \`\(created\_at, id\)\` guarantees uniqueness; the query \`WHERE \(created\_at, id\) > \(last\_created\_at, last\_id\)\` efficiently uses a composite index. Common mistake: using \`OFFSET\` for deep pagination, which degrades linearly with page depth.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:45:56.231843+00:00— report_created — created