Scan
Parameters
When you use the
--limit
parameter with thescan
operation in DynamoDB and set it to 5, it indeed instructs DynamoDB to evaluate only the first 5 items in the table.Without
--filter
: If you set--limit 5
without a filter, DynamoDB evaluates the first 5 items and returns them as the result of the scan.With
--filter
: If you set--limit 5
and also specify a--filter
expression, DynamoDB still evaluates the first 5 items. However, it only returns those that match the filter criteria. If fewer than 5 items match the filter, then fewer than 5 items are returned. If none of the first 5 items match the filter, it returns no items. In either case, it only evaluates 5 items before stopping.
If you do not use a filter expression, ScannedCount
and Count
have the same value.
The
page-size
parameter will determine the number of items returned in each page of a query.If there are more items available than the specified
--max-items
value, the response includes aNextToken
value.
Best practices
Avoid using scan operation on large table or index, use Filter --filter-expression
and Projection --projection-expression
, and --page-size
to get specific data instead.
Trivia
1 single DynamoDB scan can retrieve max 1MB.
Last updated