Reads and cost · Lesson 3 of 20
One query, a whole collection
Items that share a partition key are read together in one Query.
Why
All the items sharing a partition key form an item collection, stored together and sorted by sort key. Query reads a slice of one collection.
Here one Query returns the room and every message in it, in order, in a single round trip. The messages were written next to the room on purpose, so reading them back is one cheap operation rather than a join.
Co-locate what you read together. Then a Query reads it all at once, cheaply.
Chatdynoxide · wasm · DynamoDB API 2012-08-10 · contract 1
Try an example
Every item under ROOM#general, the room meta and all its messages, in a single request.
pk(pk)
sk(sk)
topic
from
text
Run an operation to see the raw engine response.
table Chatkeys pk / skitems 22