Ravi Sir's Cards › AWS
Query vs Scan
This revision card explains Query vs Scan. It starts from the need that scan feels easy and becomes a bill shock. It describes query uses PK (and optional SK). Scan reads the table; you pay for examined items. The how-to section notes always design a key that lets you Query. Use Scan only for tiny labs or rare admin jobs. An example on the card is list notes for user 7 , then Query PK=7. Scan whole table , then expensive.
Read card text
What this card says
Why do we need it?
Scan feels easy and becomes a bill shock.
What is it?
Query uses PK (and optional SK). Scan reads the table; you pay for examined items.
How to do it
Always design a key that lets you Query. Use Scan only for tiny labs or rare admin jobs.
KeyConditionExpression
Example
List notes for user 7 → Query PK=7. Scan whole table → expensive.