dynamo DB pagination last page

0

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 réponse
1

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:

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html#DDB-Query-request-ScanIndexForward

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

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html#DDB-Scan-request-TotalSegments

profile pictureAWS
EXPERT
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions