Skip to content
Scan vs. Query Exam Tips
- A Query operation finds items in a table using only the Primary Key attribute.
- You provide the Primary Key name and a distinct value to search for.
- A Scan operation examines every item in the table.
- By default, returns all data attributes
- Use the ProjectionExpression parameter to refine the results
- Query results are always sorted by the Sort Key, if there is one.
- Sorted in ascending order.
- Set ScanIndexForward parameter to false to reverse the order (Queries only).
- Query operation is generally more efficient than a Scan.
- Reduce the impact of query or scan by setting a smaller page size, which uses fewer read operations and/or by running parallel scans
- Isolate scan operations to specific tables and segregate them from your mission-critical traffic.
- Try Parallel scans, rather than the default sequential scan.
- Avoid using scan operations if you can. Design tables in a way that you can use the Query, Get, or BatchGetItem APIs.
- BatchGetItem is used to retrieve multiple items from a DynamoDB table.
- Remember Scan returns everything (not filtered down by Partition Key)