Reads and cost · Lesson 4 of 20
The sort key is a query language
Conditions on the sort key narrow a Query before it reads, for free.
Why
On the sort key a Query can do more than equals: begins_with, a range with BETWEEN, or simple comparisons like greater-than. Because the partition is already sorted, these narrow the read before it happens.
Run all three and watch the cost. Scanned never climbs above Returned: the key condition decided what to read, so you never pay for items you did not want.
Sort-key conditions narrow before the read. Sorting your data is designing your queries.
Chatdynoxide · wasm · DynamoDB API 2012-08-10 · contract 1
Try an example
No sort-key condition: the room meta and every message.
pk(pk)
sk(sk)
topic
from
text
Run an operation to see the raw engine response.
table Chatkeys pk / skitems 22