Skip to content

Paginate by creation time instead of key order#96

Open
benthecarman wants to merge 1 commit intolightningdevkit:mainfrom
benthecarman:creation-pagination
Open

Paginate by creation time instead of key order#96
benthecarman wants to merge 1 commit intolightningdevkit:mainfrom
benthecarman:creation-pagination

Conversation

@benthecarman
Copy link
Copy Markdown

Clients often need to fetch recent payments or entries without iterating over the entire keyspace. Ordering by created_at lets callers retrieve the newest records first and stop early, which is not possible with lexicographic key ordering.

The page token now encodes (created_at, key) so the cursor remains unique even when multiple rows share the same timestamp. A composite index on (user_token, store_id, created_at, key) keeps the query efficient, and a migration back-fills any NULL created_at values and adds the NOT NULL constraint.

@benthecarman benthecarman requested a review from tankyleo April 2, 2026 01:55
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Apr 2, 2026

👋 Thanks for assigning @tankyleo as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Clients often need to fetch recent payments or entries without
iterating over the entire keyspace. Ordering by created_at
lets callers retrieve the newest records first and stop early,
which is not possible with lexicographic key ordering.

The page token now encodes (created_at, key) so the cursor
remains unique even when multiple rows share the same timestamp.
A composite index on (user_token, store_id, created_at, key)
keeps the query efficient, and a migration back-fills any NULL
created_at values and adds the NOT NULL constraint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@benthecarman benthecarman force-pushed the creation-pagination branch from defad39 to cb70f98 Compare April 2, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants