All posts
Data Platform

DynamoDB vs Postgres, Measured: One Orders Dataset, Seven Questions, Three Sizes

By

November 4, 2026

8 min read

We loaded the same orders into Postgres 17 and DynamoDB and asked seven questions at 100,000, 1 million and 5 million orders. Lookups by key stayed under 2 ms in Postgres at every size and cost half a read unit in DynamoDB. Every question across customers needed a full Scan in DynamoDB (about 40,000 read units per million orders), and took 0.02 to 1.6 seconds in Postgres. The numbers, and what they mean for choosing.

DynamoDB
Postgres
Benchmark
Research

The setup

  • An orders table: order ID, customer (50,000 of them), timestamp over two years, status, region, total, and one to five line items. Average DynamoDB item 327 bytes.

  • Postgres 17 in Docker on an Apple M4 laptop, default settings, a primary key and one index on (customer, created_at). Timings are medians of repeated runs over one local connection.

  • DynamoDB modelled the usual way: partition key per customer, sort key by date, and a secondary index by order ID. We measured what each operation consumes, not its speed: DynamoDB Local is an emulator, and AWS quotes single-digit millisecond latency for key lookups on the real service.

Order by ID0.22 ms0.23 ms0.35 msA customer's last 20 orders0.23 ms0.38 ms1.6 msRevenue by region and month24 ms284 ms1.6 sTop 10 customers, 90 days (join)18 ms181 ms1.4 sTop 20 SKUs, 30 days (JSON)11 ms65 ms1.4 sBig refunds, 30 days (unplanned)2.0 ms56 ms1.2 sSame, after adding an index0.62 ms2.3 ms50 ms

100,000 orders

1 million orders

5 million orders

Postgres 17, median time per query (log scale). At 5 million orders the table and indexes (4.2 GB) no longer stayed in memory, which is why times jump more than the row count.

The data
100,000 orders1 million orders5 million orders
Order by ID0.22 ms0.23 ms0.35 ms
A customer's last 20 orders0.23 ms0.38 ms1.6 ms
Revenue by region and month24 ms284 ms1.6 s
Top 10 customers, 90 days (join)18 ms181 ms1.4 s
Top 20 SKUs, 30 days (JSON)11 ms65 ms1.4 s
Big refunds, 30 days (unplanned)2.0 ms56 ms1.2 s
Same, after adding an index0.62 ms2.3 ms50 ms

Question

DynamoDB operation

Read units at 1M orders

Cost per run

Order by ID

Query on the order-ID index

0.5

$0.00000006

A customer's last 20 orders

Query on the customer's partition

1

$0.00000013

Revenue by region and month

Scan of the whole table

About 40,150

About $0.005

Top 10 customers, 90 days

Scan

About 40,150

About $0.005

Top 20 SKUs, 30 days

Scan

About 40,150

About $0.005

Big refunds, 30 days

Scan with a filter: reads 200,000 items to return 620

About 40,150

About $0.005

Same, after adding an index

A new secondary index, backfilled across every item

0.5 per lookup, plus a write per item to build

Every future order costs one more write

Measured on 200,000 orders (8,030.5 read units for the scan, 63 pages of 1 MB) and scaled linearly; eventually consistent reads at $0.125 per million.

What the numbers say

  • Questions you designed for are cheap and flat in both. Postgres stayed under 2 ms at 5 million orders; DynamoDB stays at half a read unit at any size, which is its real advantage at hundreds of millions of items.

  • Questions you didn't design for are where they part. Postgres answers them, slowly at first, and an index built in 2 seconds took the unplanned one from 1.2 s to 50 ms at 5 million orders. DynamoDB answers them with a Scan.

  • A Scan is cheap in dollars at this size (half a cent per million orders) and expensive in everything else: 315 sequential 1 MB pages per million items, throughput other requests also need, and code to aggregate in your application.

  • Filters don't make scans cheaper. The refund question read every item to return 0.3% of them, and paid for all of it.

Choosing between DynamoDB and Postgres for a new service?

Bring your access patterns and the reports someone will ask for next quarter. We'll tell you which fits, in 30 minutes, free.

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.