0
0
DynamoDBquery~5 mins

When Scan is acceptable in DynamoDB

Choose your learning style9 modes available
Introduction
Scan reads every item in a table. It is simple but can be slow. Use it only when you need to check all data or have no better way to find what you want.
You want to get all items from a small table quickly.
You need to find items but have no suitable key to query.
You want to check or count all items in the table.
You are testing or debugging and want to see all data.
You have a filter that cannot use indexes or keys.
Syntax
DynamoDB
Scan
  TableName: string
  FilterExpression?: string
  ExpressionAttributeValues?: map
  ProjectionExpression?: string
Scan reads every item in the table, so it can be slow for big tables.
Use FilterExpression to narrow results after scanning all items.
Examples
Get all items from the Books table.
DynamoDB
Scan
  TableName: "Books"
Get all books where the author is Alice by scanning and filtering.
DynamoDB
Scan
  TableName: "Books"
  FilterExpression: "Author = :a"
  ExpressionAttributeValues: {":a": "Alice"}
Sample Program
This scan gets all movies from 2020 or later by scanning the whole Movies table and filtering by year.
DynamoDB
Scan
  TableName: "Movies"
  FilterExpression: "Year >= :year"
  ExpressionAttributeValues: {":year": 2020}
OutputSuccess
Important Notes
Scan reads the entire table, so it uses more read capacity and takes longer than Query.
For large tables, consider using Query with keys or indexes for better speed.
Use Scan only when you cannot use Query or need all data.
Summary
Scan reads every item in a table and is simple but slow for big data.
Use Scan for small tables, no key available, or when you need all data.
FilterExpression helps reduce results after scanning.