Querying & Sorting

Reads are where the bill gets written. Query targets one item collection by key; Scan reads the whole table. Reach for Scan with a filter — the SQL instinct — and you pay for every item read, not the few you keep. That's the classic footgun.

This section is about reading efficiently: using the key to do the work, paging correctly, and ordering results with the sort key instead of in-memory sorting.

0 of 10 readQuiz
Query vs Scan in DynamoDB
When to use Query vs Scan in DynamoDB, why Scan is almost never what you want, and how to model your keys so Query covers your access patterns.
Beginner4 min read
Pagination in DynamoDB
Paginate DynamoDB results correctly with LastEvaluatedKey and ExclusiveStartKey, why Limit isn't a page size, and how to expose a stateless cursor to clients.
Beginner4 min read
DynamoDB Filtering Strategies
DynamoDB filtering strategies compared — partition key, sort key, sparse indexes, and FilterExpression — and which one actually cuts your read bill.
Intermediate7 min read
Why a DynamoDB Scan Is Slow and Expensive
Why a DynamoDB Scan is slow and expensive, what it actually bills you for, and how to turn a reflexive Scan into a keyed Query that costs a fraction.
Beginner6 min read
DynamoDB Parallel Scans
How DynamoDB parallel scans split a full-table read across workers with Segment and TotalSegments, when they help, and the throughput footgun to avoid.
Advanced6 min read
DynamoDB Sort Key Strategies
DynamoDB sort key strategies — design sortable sort keys for range queries, ordering, and multiple access patterns in one item collection, with a worked audit-log example.
Intermediate8 min read
How to Query DynamoDB in Descending Order
How to query DynamoDB in descending order with ScanIndexForward=false — newest-first results, why sort happens on the sort key, and how to page backward efficiently.
Beginner5 min read
Sorting DynamoDB on a Changing (Mutable) Attribute
Sorting DynamoDB on a changing attribute — why you can't update a key attribute in place, the delete-and-recreate pattern, and using a GSI so the volatile value lives off the base-table key.
Intermediate5 min read
Zero-Padding Sort Keys in DynamoDB
DynamoDB zero-padding sort keys — why "10" sorts before "2" in a string sort key, and how fixed-width zero-padded numbers make string order match numeric order.
Intermediate5 min read
Knowledge checkTake the quiz
Check what you’ve learned in this section.

Start with Query vs Scan — it's the decision the rest depend on.

Try DynoTable to run these queries against a live table.