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개 답변
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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠