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
preguntada hace un año451 visualizaciones
1 Respuesta
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
EXPERTO
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas