All posts
Data Platform

Using DynamoDB Well: A Worked Single-Table Design, From Access Patterns to Keys

By

November 4, 2026

7 min read

DynamoDB rewards designing from the questions backwards. A worked example for orders and customers: the access-pattern table, the keys and items, one overloaded secondary index, a sparse index for open orders, and how item size sets the bill (a 4.1 KB item costs twice as much to read as a 4.0 KB one).

DynamoDB
Data Modeling
Serverless

1. Write down the questions first

Access pattern

Key condition

Index

Get a customer's profile

PK = C#<customerId>, SK = PROFILE

Table

A customer's recent orders

PK = C#<customerId>, SK begins_with O#, newest first

Table

Get an order by ID

GSI1PK = O#<orderId>

GSI1

An order's line items

PK = O#<orderId>, SK begins_with L#

Table

Open orders for the warehouse, oldest first

GSI2PK = OPEN, sorted by created time

GSI2 (sparse: only open orders carry the key)

PK = C#1042 (a customer)

SK = PROFILE: name, email, region
SK = O#2026-11-03#88121: total, status
SK = O#2026-10-19#87002: total, status

One Query returns the profile and recent orders together.

PK = O#88121 (an order)

SK = L#1: SKU-00412 × 2
SK = L#2: SKU-01877 × 1

Line items live with their order, not their customer.

GSI1 (order ID)

GSI1PK = O#88121 → the order summary

GSI2 (sparse)

GSI2PK = OPEN only while status is placed or packed

Remove the attribute when the order ships and it leaves the index.

Items in one table, grouped by partition key

2. Keep items small, because size is the bill

1 KB$0.063$0.125$0.2504 KB$0.063$0.125$0.2504.1 KB$0.125$0.250$0.5008 KB$0.125$0.250$0.50016 KB$0.250$0.500$1.0040 KB$0.625$1.25$2.50100 KB$1.56$3.13$6.25

Eventually consistent

Strongly consistent

Transactional

Cost per million reads by item size, US East on-demand. Reads are charged per 4 KB, rounded up; $0.125 per million read request units.

The data
Eventually consistentStrongly consistentTransactional
1 KB$0.063$0.125$0.250
4 KB$0.063$0.125$0.250
4.1 KB$0.125$0.250$0.500
8 KB$0.125$0.250$0.500
16 KB$0.250$0.500$1.00
40 KB$0.625$1.25$2.50
100 KB$1.56$3.13$6.25
0.5 KB$0.625$1.251 KB$0.625$1.251.1 KB$1.25$2.504 KB$2.50$5.0010 KB$6.25$12.5040 KB$25.00$50.00

Standard write

With one secondary index projecting the item

Cost per million writes by item size. Writes are charged per 1 KB, rounded up; $0.625 per million write request units. An index that projects the item is written too.

The data
Standard writeWith one secondary index projecting the item
0.5 KB$0.625$1.25
1 KB$0.625$1.25
1.1 KB$1.25$2.50
4 KB$2.50$5.00
10 KB$6.25$12.50
40 KB$25.00$50.00

3. Rules that keep it working

  • Short attribute names: they are stored, and billed, on every item.

  • Large or rarely read data (documents, images, long text) in S3, with the key in the item.

  • Project only what an index needs (KEYS_ONLY or INCLUDE), since every projected byte is written twice.

  • Prefer eventually consistent reads unless the screen must show a write the same user just made.

  • Never Scan in a request path. If a question needs a Scan, it needs an index, a Stream-fed aggregate, or a different database.

Designing a DynamoDB table for a new feature?

Bring your access patterns. We'll sketch the keys and indexes with you and tell you if Postgres would be simpler. Free, 30 minutes.

hoolco Monthly Review

Once a month: what changed in tech that month and what it means for you, from cloud and AI to security and the tools you build with. Every item links to its source. No sales pitch, unsubscribe in one click.

As of November 4, 2026. Provided as is, for general information, and accurate to the best of our knowledge on the date shown. Not legal, compliance, tax, financial or other professional advice. Prices, limits and vendor services change; check current vendor documentation before relying on anything here. Terms of use.