Read a page, keep the bookmark
Limit caps a page; LastEvaluatedKey is the bookmark you feed back to resume.
Why
This feed has nine posts and we want them four at a time. Limit caps a page at four, then the response carries a LastEvaluatedKey, the key of the last row it read. That is a resumable bookmark, not an offset.
Run the pages in order. Page two passes the bookmark back as ExclusiveStartKey and carries on. The last page returns one post and no LastEvaluatedKey at all: the missing bookmark is the end-of-results signal. There is no OFFSET in DynamoDB, and it never counts past where it stopped.
LastEvaluatedKey is a resumable bookmark, and its absence means the last page. Loop until the bookmark is gone, never on a count.
Try it. Then change it.
Predict what each request will do. Run it, inspect the response, then change a value in the workbench and try again.
Limit 4 returns the first four posts. The response carries a LastEvaluatedKey: the key of the last row, your bookmark.
Feed the bookmark back as ExclusiveStartKey to resume exactly where page one stopped. No re-reading.
From the page-two bookmark only one post is left, and the response has no LastEvaluatedKey. That absence is how you know you are done.
Built on this
- Notifications Feed - What’s new for this user?
Limit 4 returns the first four posts. The response carries a LastEvaluatedKey: the key of the last row, your bookmark.
Choose an access pattern above, or build your own request. See what comes back and what it costs.