Skip to content

Keep the total where you read it

A denormalised count on the parent turns an aggregate into a single GetItem.

Why

How many replies does a thread have? You could read them all and count, but that read grows without bound as the thread fills up. Instead the count lives on the thread's META item as a denormalised attribute.

So the total is a single GetItem, however long the thread runs. When a reply is posted, ADD bumps replyCount atomically on the server, so two replies at once can never lose each other. The trade is honest: the counter and the reply are two writes, so keeping them exactly in step needs a transaction.

Store the aggregate on the parent and bump it with atomic ADD; reading the total is one GetItem, not a query-and-sum that grows.

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. The thread's META item carries replyCount. The total is one item read, no children touched.

  2. The alternative: read every reply and count them. More cost, and it grows with the thread.

  3. ADD increments replyCount atomically on the server. Run it after a reply is posted; concurrent posts can never lose a count.

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

The thread's META item carries replyCount. The total is one item read, no children touched.

Request
Execute against the local Dynoxide engine
ReturnedFiltered outChanged
pk(pk)
sk(sk)
title
replyCount
author
body
THREAD#dovetails
METAS
Hand-cut dovetailsS
3N
—
—
THREAD#dovetails
REPLY#2026-06-01T10:00S
—
—
adaS
Mark the baseline first.S
THREAD#dovetails
REPLY#2026-06-01T11:30S
—
—
rajS
A sharp chisel does the work.S
THREAD#dovetails
REPLY#2026-06-01T14:00S
—
—
meiS
Saw to the line, not over it.S
THREAD#finishes
METAS
Shellac vs oilS
2N
—
—
THREAD#finishes
REPLY#2026-06-02T09:00S
—
—
adaS
Shellac for speed.S
THREAD#finishes
REPLY#2026-06-02T12:00S
—
—
rajS
Oil for depth.S
THREAD#sharpening
METAS
Waterstones grit orderS
4N
—
—
THREAD#sharpening
REPLY#2026-06-03T08:00S
—
—
meiS
1000 then 6000.S
THREAD#sharpening
REPLY#2026-06-03T09:15S
—
—
adaS
Flatten the stone often.S
THREAD#sharpening
REPLY#2026-06-03T10:30S
—
—
rajS
A strop to finish.S
THREAD#sharpening
REPLY#2026-06-03T13:00S
—
—
meiS
Test on end grain.S
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