Skip to content

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.

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.

  1. No sort-key condition: the room meta and every message.

  2. begins_with(sk, 'MSG#') skips the META item and returns just the messages.

  3. sk > a timestamp returns only the later messages. Sorted keys make 'latest' a key condition, not a filter.

Built on this

ChatDynamoDB workbench
Ready to run
Explore an access patternSelect to load & run

No sort-key condition: the room meta and every message.

Request
Execute against the local Dynoxide engine
ReturnedFiltered outChanged
pk(pk)
sk(sk)
topic
from
text
ROOM#general
METAS
Anything goesS
—
—
ROOM#general
MSG#2026-06-01T09:00S
—
adaS
morning allS
ROOM#general
MSG#2026-06-01T09:05S
—
linusS
coffee firstS
ROOM#general
MSG#2026-06-01T11:20S
—
graceS
standup in 10S
ROOM#general
MSG#2026-06-01T15:40S
—
adaS
PR up for reviewS
ROOM#general
MSG#2026-06-02T08:30S
—
linusS
merged, thanksS
ROOM#general
MSG#2026-06-02T14:00S
—
graceS
ship itS
ROOM#general
MSG#2026-06-02T16:15S
—
adaS
deploying nowS
ROOM#general
MSG#2026-06-03T09:10S
—
graceS
all greenS
ROOM#random
METAS
Off topicS
—
—
ROOM#random
MSG#2026-06-01T12:00S
—
adaS
lunch?S
ROOM#random
MSG#2026-06-01T12:30S
—
linusS
tacosS
ROOM#random
MSG#2026-06-02T17:00S
—
graceS
weekend plans?S
ROOM#random
MSG#2026-06-03T13:00S
—
adaS
hikingS
ROOM#design
METAS
Design critsS
—
—
ROOM#design
MSG#2026-06-01T10:00S
—
maraS
new mock in figmaS
ROOM#design
MSG#2026-06-02T11:00S
—
adaS
love the spacingS
ROOM#design
MSG#2026-06-02T13:30S
—
maraS
tweaked the typeS
ROOM#support
METAS
Customer issuesS
—
—
ROOM#support
MSG#2026-06-01T08:00S
—
samS
ticket 1042 escalatedS
ROOM#support
MSG#2026-06-02T09:30S
—
samS
resolvedS
ROOM#support
MSG#2026-06-03T10:00S
—
adaS
nice workS
Awaiting request
Your next query starts here.

Choose an access pattern above, or build your own request. See what comes back and what it costs.

Powered by DynoxideWASMStarts on your first run · Runs locally in your browser