accesspatterns.dev

Reads and cost · Lesson 7 of 20

Read a page, keep the bookmark

Limit caps a page; LastEvaluatedKey is the bookmark you feed back to resume.

Next · Writing dataPutItem replaces

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.

Episodes
Try an example

Limit 4 returns the first four posts. The response carries a LastEvaluatedKey: the key of the last row, your bookmark.

pk(pk)
sk(sk)
title
mins

Run an operation to see the raw engine response.

table Episodeskeys pk / skitems 9