accesspatterns.dev

Read the latest first

A sorted timestamp makes 'the most recent' a direction, not a sort in your code.

Why

Every reading from a fridge shares that fridge's partition key, and the sort key is an ISO-8601 timestamp. A fixed-width ISO timestamp sorts lexically in time order, so the newest reading is simply the last one in the partition.

That makes 'the latest' a direction. ScanIndexForward false walks the partition newest-first, and a Limit stops it early. Run all three: direction and limit are request fields, not a second query and a sort back in your own code.

Sort by a fixed-width timestamp and the latest N is a descending Query with a Limit, never a scan-then-sort.

ColdChain

These rows are real and already here. Running an operation against them downloads a DynamoDB-compatible engine, about 850 KB, and executes it in this tab.

Try an example

ScanIndexForward false reads the partition newest-first, and Limit 1 stops at the top row.

pk(pk)
sk(sk)
tempC
door
FRIDGE#a
2026-06-20T06:00:00ZS
5.1N
falseBOOL
FRIDGE#a
2026-06-20T08:00:00ZS
5.4N
falseBOOL
FRIDGE#a
2026-06-20T10:00:00ZS
6N
trueBOOL
FRIDGE#a
2026-06-20T12:00:00ZS
7.2N
trueBOOL
FRIDGE#b
2026-06-20T06:00:00ZS
3N
falseBOOL
FRIDGE#b
2026-06-20T08:00:00ZS
3.1N
falseBOOL
FRIDGE#b
2026-06-20T10:00:00ZS
2.9N
falseBOOL
FRIDGE#b
2026-06-20T12:00:00ZS
3.4N
falseBOOL
FRIDGE#c
2026-06-20T06:00:00ZS
4.5N
falseBOOL
FRIDGE#c
2026-06-20T08:00:00ZS
4.4N
falseBOOL
FRIDGE#c
2026-06-20T10:00:00ZS
4.6N
falseBOOL

Run an operation to see the raw engine response.

table ColdChainkeys pk / skitems 11