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?

Jess
已提问 1 年前470 查看次数
1 回答
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
专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则