amazon-dynamodbdynamodb-queries

What exactly is Limit in Dynamodb?


From AWS Docs:

A single Query operation can retrieve a maximum of 1 MB of data. This limit applies before any FilterExpression or ProjectionExpression is applied to the results. If LastEvaluatedKey is present in the response and is non-null, you must paginate the result set.

I have been working on DynamoDB for sometime now, when I increase limit of a query it would always give me more records. So What's the closest meaning of Limit = 2? returning 2 items (or max 1 MB which we know for the fact) right? So, would that make Limit=1000; return 1000 items or 1000 MBs of data? Or 1000 records and no effect on data size? Or anything else?


Solution

  • The limit parameter only affects the number of items that are returned.

    Limit = 2 means at most 2 items will be returned. The upper limit for the limit parameter is 1000 - one API call can't return more than 1000 items.

    Depending on the item size, you may not get all the records that you specify with the limit parameter, because at most 1MB of data is read from the table. That means if all items in your table are 400KB in size each (the max per item) and you set the limit parameter to 5, you will always get at most 2 items from the table, because of the 1MB limit.