B. FilterExpression syntax is incorrect, causing scan to fail
C. Scan does not support FilterExpression
D. FilterExpression is applied after scan reads all items, so no items match age > 30
Solution
Step 1: Understand FilterExpression in scan
FilterExpression filters results after scanning all items; if no items match, result is empty.
Step 2: Check syntax and params
Syntax is correct, TableName is present, and scan supports FilterExpression.
Final Answer:
FilterExpression is applied after scan reads all items, so no items match age > 30 -> Option D
Quick Check:
FilterExpression filters after scan [OK]
Hint: FilterExpression filters after scan reads all items [OK]
Common Mistakes:
Thinking FilterExpression prevents scanning items
Assuming scan fails with FilterExpression
Missing TableName parameter
5. You want to scan a large DynamoDB table but only retrieve items where status is 'active'. Which approach is best to reduce data returned and improve performance?
hard
A. Use scan with FilterExpression 'status = :s' and ExpressionAttributeValues { ':s': 'active' }
B. Use query operation with status as partition key
C. Use scan without filters and filter results in application code
D. Use scan with ProjectionExpression to get only 'status' attribute
Solution
Step 1: Understand scan vs query
Scan reads entire table; query reads items by key, more efficient for filtering.
Step 2: Check if status can be partition key
If status is partition key, query can efficiently get only 'active' items without scanning all.
Step 3: Evaluate other options
FilterExpression filters after scan, so less efficient; filtering in app wastes bandwidth; ProjectionExpression only limits attributes, not items.
Final Answer:
Use query operation with status as partition key -> Option B
Quick Check:
Query with key filters efficiently [OK]
Hint: Query by key is faster than scan with filters [OK]
Common Mistakes:
Relying on scan with filters for large tables
Filtering data in application instead of query
Confusing ProjectionExpression with filtering items