0
0
DynamoDBquery~10 mins

Scan with filter expressions in DynamoDB - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Scan with filter expressions
Start Scan
Read all items
Apply Filter Expression
Yes No
Keep
Return filtered items
End
Scan reads all items, then filter expression keeps only matching items before returning.
Execution Sample
DynamoDB
Scan table 'Books' with filter: Author = 'Alice'
Return only items where Author is 'Alice'
This scan reads all books but returns only those written by Alice.
Execution Table
StepItem ReadFilter Condition (Author='Alice')ResultAction
1{"Title":"Book1","Author":"Alice"}TrueKeepAdd to result
2{"Title":"Book2","Author":"Bob"}FalseDiscardSkip
3{"Title":"Book3","Author":"Alice"}TrueKeepAdd to result
4{"Title":"Book4","Author":"Carol"}FalseDiscardSkip
5{"Title":"Book5","Author":"Alice"}TrueKeepAdd to result
End---All items scanned, filtered results returned
💡 All items scanned; only items with Author='Alice' kept
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5Final
Current ItemNone{"Title":"Book1","Author":"Alice"}{"Title":"Book2","Author":"Bob"}{"Title":"Book3","Author":"Alice"}{"Title":"Book4","Author":"Carol"}{"Title":"Book5","Author":"Alice"}None
Result Set[][Book1][Book1][Book1, Book3][Book1, Book3][Book1, Book3, Book5][Book1, Book3, Book5]
Key Moments - 3 Insights
Why does the scan read all items even if we only want some?
Scan reads every item first because filter expressions are applied after reading all items, as shown in execution_table rows 1-5.
Does the filter expression reduce read capacity usage?
No, filter expressions do not reduce read capacity because all items are read first; filtering happens after, as seen in the 'Action' column.
What happens to items that do not match the filter?
Items not matching the filter are discarded and not added to the result set, as shown in rows 2 and 4 of execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what happens at step 3?
AItem is kept because Author is Alice
BItem is discarded because Author is not Alice
CScan stops at this step
DFilter expression is not applied
💡 Hint
Check the 'Filter Condition' and 'Result' columns at step 3 in execution_table
At which step does the filter expression first discard an item?
AStep 1
BStep 4
CStep 2
DStep 5
💡 Hint
Look for the first 'Discard' in the 'Result' column in execution_table
If the filter was changed to Author='Bob', how would the result set change after step 5?
AResult set would include Book1, Book3, and Book5
BResult set would include only Book2
CResult set would be empty
DResult set would include all books
💡 Hint
Refer to variable_tracker 'Result Set' and which items have Author='Bob'
Concept Snapshot
Scan reads all items in a table.
Filter expressions apply after reading.
Only items matching filter are returned.
Filter does not reduce read cost.
Useful for simple filtering without indexes.
Full Transcript
In DynamoDB, a scan operation reads every item in a table. After reading, it applies a filter expression to decide which items to keep. Items that match the filter are included in the results; others are discarded. This means the scan reads all data first, so filter expressions do not reduce the amount of data read or the read capacity used. For example, scanning a 'Books' table with filter Author='Alice' reads all books but returns only those by Alice. This process is shown step-by-step in the execution table and variable tracker, helping beginners see how each item is processed and filtered.