Does a paginated scan return pages in a deterministic or undermistic order?


Say my table looks like this:

                               |                attributes
 partition key: username       |        gender       |        age

I would like it to be possible for a user to go through all rows in this table (a little by a little, meaning, in a paginated way). Obviously, a paginated scan should do the job here. But now, my worry is that this will result in the first item in the table being accessed way more than the remaining items (which is bad).

Is this really the case? Will a paginated scan always return items in a deterministic manner? (From start to end of table). Or will it scan through the whole table in a random fashion?

preguntada hace 2 años624 visualizaciones
2 Respuestas

Items have an internal order that's used during scans. You can't predict from the outside what the order will be because it's based on things like the hashes of PK values.

You want a semi-random item from the table? You can use the parallel scan functionality and specify up to a million segments and pick a random segment number to start your scan from. That would give you a million starting points (evenly distributed among the internal order of items).

respondido hace 2 años
  • I don't know why you mention parallel scans all of a sudden, is not possible to pick a random segment number to start a scan from with a regular scan? Also, just to be clear, are you then saying that a regular scan with a random segment number to start the scan from will be what you would advice in my situation (and that it would be a good solution)?

  • To be clear, I didn't say to do a parallel scan. I said to use the parallel scan functionality which lets you split the scan into segments and you can pick a random one to read from. That was assuming you wanted a random item. I can't really give advice for your situation since you only asked about scan behaviors and didn't give your requirements. Are your requirements to pick a single random item from a table?


DynamoDB paginates the results from Scan operations. With pagination, the Scan results are divided into "pages" of data that are 1 MB in size (or less). An application can process the first page of results, then the second page, and so on. A single Scan only returns a result set that fits within the 1 MB size limit.

Please read through the below links to get more information regarding the same.

Link- -- [1] -- [2]

profile pictureAWS
respondido hace 2 años

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