accesspatterns.dev

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.

Episodes

These rows are real and already here. Running an operation against them downloads a DynamoDB-compatible engine, about 850 KB, and executes it in this tab.

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
FEED#latenight
POST#0001S
Ep 1: KrautrockS
58N
FEED#latenight
POST#0002S
Ep 2: DubS
47N
FEED#latenight
POST#0003S
Ep 3: Jazz-funkS
52N
FEED#latenight
POST#0004S
Ep 4: Library musicS
41N
FEED#latenight
POST#0005S
Ep 5: ItaloS
55N
FEED#latenight
POST#0006S
Ep 6: MinimalS
49N
FEED#latenight
POST#0007S
Ep 7: Spoken wordS
44N
FEED#latenight
POST#0008S
Ep 8: Field recordingsS
62N
FEED#latenight
POST#0009S
Ep 9: AmbientS
60N

Run an operation to see the raw engine response.

table Episodeskeys pk / skitems 9