accesspatterns.dev

Foundations · Lesson 2 of 20

The key is the address

GetItem needs the whole primary key: partition and sort.

Next · Reads and costOne query, a whole collection

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.

Chat
Try an example

The full key: the room (partition) and the message id (sort). One item, the cheapest read there is.

pk(pk)
sk(sk)
topic
from
text

Run an operation to see the raw engine response.

table Chatkeys pk / skitems 22