1.DynamoDB Core Vocabulary
A table holds items (rows); each item holds attributes (columns), schemaless beyond the primary key. A partition key alone must be unique per item; a composite key (partition + sort) lets multiple items share a partition key, sorted by sort key. A Query fetches by key efficiently; a Scan reads the whole table and is expensive at any real size. A GSI has its own partition/sort key (queryable independent of the base table's key); an LSI shares the base table's partition key with a different sort key, and must be created at table creation time.
Key features
- Partition key alone: must be unique per item. Composite key (partition + sort): partition key can repeat, but the pair must be unique
- Query: efficient, uses the key structure directly. Scan: reads the entire table (or index), filtering happens after the read — expensive at any real table size
- GSI: its own partition/sort key, queryable independently — can be added after table creation, up to 20 per table by default
- LSI: shares the base table's partition key with a different sort key — must be created at table creation time, up to 5 per table
- Every partition delivers up to 3,000 read units and 1,000 write units per second — a single item's size determines exactly how many units each operation consumes
- DynamoDB Streams captures item-level change events (before/after images), retained for 24 hours — often consumed via a Lambda trigger
- Query
- Uses the key structure directly
- Reads only the matching partition (+ sort range)
- Cheap and fast at any table size
- Scan
- Reads the entire table or index
- Filters happen after the read, not before
- Cost grows with table size, regardless of result size
Signature
Query (key-based, cheap) vs Scan (full read, expensive) · GSI (own key, anytime) vs LSI (shared key, at creation)
Partition key alone must be unique; composite key lets the partition repeat, pair must be unique. Query uses the key structure (cheap); Scan reads everything then filters (expensive at scale). GSI: own key, addable anytime. LSI: shares the base partition key, must be defined at table creation.