dynamo DB pagination last page


Hi Team,

I'm implementing pagination using AWS dynamoDB

I have in my UI 4 buttons

  • first
  • next
  • previous
  • last

I'm getting data by segments of 25 rows to avoid to do full table scan.

when the user click the last button to go directly to the last page,

do I need to do a full table scan for that? or is there a way to get the 25 last rows instead of doing full table scan when we click on the "last" button?

1 Answer

If your API call is a Query then when the user clicks on the last row, you simply set ScanIndexForward to False, this reverses the order of the Query:


If you are doing a Scan with a limit, then you would need to be a little smarter about things. You would need to break your table up into segments, then use a segmented Scan to get the last portion of data, for example:

aws dynamodb scan \
    --table-name MusicCollection \
    --total-segments 4 \
    --segment 3


profile picture
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions