The key is the address
GetItem needs the whole primary key: partition and sort.
Why
This table has a composite key: a partition key (pk, the room) and a sort key (sk, the message). The partition key decides which partition an item lives on; the sort key orders items within that partition.
GetItem fetches exactly one item, and it needs the whole key. Knowing only the room is not enough to GetItem a message. That is a job for Query, next.
Know the full key, pay for one item. GetItem is the cheapest read DynamoDB offers.
Try it. Then change it.
Predict what each request will do. Run it, inspect the response, then change a value in the workbench and try again.
The full key: the room (partition) and the message id (sort). One item, the cheapest read there is.
Built on this
- URL Shortener - Where does this short link go?
- Feature Flags - Which features are enabled here?
- Web Sessions - Who owns this session?
- Verification Service - Is this code still valid?
- Idempotency Keys - Have we handled this request already?
- SaaS Multi-Tenant - What belongs to this tenant?
- Job Board - Which jobs are open right now?
- Library Management - Which loans are overdue?
- Game Leaderboard - Who’s at the top?
- University Portal - Who is enrolled on this course?
- More Like This - What else is like this item?
The full key: the room (partition) and the message id (sort). One item, the cheapest read there is.
Choose an access pattern above, or build your own request. See what comes back and what it costs.