Beginner6 min read

Why a DynamoDB Scan Is Slow and Expensive

A Scan reads every item in the table and only filters afterward. It is the operation you reach for out of SQL muscle memory, and it bills the whole table while making your latency worse than the RDS box you left.

Why is my DynamoDB Scan slow and expensive?

A Scan reads every item in the table before the FilterExpression runs, so you pay to read the whole table no matter how few rows come back, and it gets slower as the table grows. The fix is almost always a keyed Query: model the access pattern around a key so DynamoDB reads one item collection instead of everything.

  • Table size, not result count, decides the bill. Returning 12 items can bill for reading 12 million.
  • A keyed Query stays flat as the table grows. It reads one , however big the rest of the table gets.
  • If you Scan to answer a routine question, you are missing a key. Tuning the filter won't fix it.

What a Scan actually does

Coming from SQL, SELECT * FROM events WHERE type = 'login_failed' feels free: the engine has an index, or it doesn't, but either way you get rows back. In DynamoDB there is no query planner deciding that for you.

A Scan walks the entire table sequentially, 1 MB at a time, and hands each page to your FilterExpression. Whatever the filter rejects is still read, still metered, and still on your bill. (AWS: Scanning tables)

That is the trap. The filter looks like a WHERE clause, but it changes the result set, never the cost. A Scan consumes the same read capacity whether or not a filter is present. (AWS: Scanning tables)

Count the read units

DynamoDB meters reads in (RCUs). One RCU buys a read of up to 4 KB; reads cost half that.

Query and Scan add up the size of every item they read on a page and round the total, not each item, up to the next 4 KB (AWS: read and write operations). Query vs Scan has the full cost table and the list price.

Take an analytics table, ProductEvents. Each row is one tracked event in a SaaS app:

PK  = "TENANT#acme"
SK  = "TS#2026-06-23T14:08:55Z#evt_9f3a"
attrs: eventType, sessionId, userId, payloadBytes

Say it holds 2,000,000 events, each ~1 KB, all under one busy tenant. You want today's failed logins. The reflexive move:

Scan ProductEvents
FilterExpression: eventType = "login_failed"

That filter might return 40 rows. But the Scan read all 2,000,000 items first: ~2 GB of data, which is roughly 250,000 read units eventually consistent, to hand back 40 items.

Key the question, not the filter

Put the day in the sort key and a Query reads one day instead of the table. The filter still has to pick the failed logins out of that day:

Query ProductEvents
PK = "TENANT#acme"
AND SK begins_with "TS#2026-06-23"
FilterExpression: eventType = "login_failed"

If the day holds ~2,000 events (~2 MB), you pay for ~2 MB of reads, about 250 read units, not 2 GB. Better by three orders of magnitude, but you still read 2,000 events to get 40.

To make the read match the answer, put the event type in a key. Leave the base table alone and add a GSI whose partition key carries tenant and type:

GSI1PK = "TENANT#acme#login_failed"   GSI1SK = "TS#2026-06-23T14:08:55Z"
Query GSI1
GSI1PK = "TENANT#acme#login_failed"
AND GSI1SK begins_with "TS#2026-06-23"

Now the read is the 40 failed logins, ~40 KB, about 5 read units. The latency stays flat as the table grows, because neither Query ever looks past its key range.

Scan vs Query, metered

Scan + filterQuery on the day + filterQuery on the GSI
ReadsEvery itemOne item collection, one dayOnly the matching events
Our example~250,000 units (~2 GB)~250 units (~2 MB)~5 units (~40 KB)
LatencyGrows with table sizeFlat as the table growsFlat as the table grows
Result vs billUnrelatedBounded by the day, not the answerTrack each other

On a Scan, your result count and your bill are unrelated. A Query bounds the bill by its key range, and the tighter the key, the closer the bill gets to the answer.

Decide before you Scan

Most accidental Scans come from one question: can I name the partition I need? If yes, it is a Query. If no, add a Global Secondary Index so the question becomes one.

Query vs Scan walks the decision, and single-table design shows how to model keys around access patterns up front.

When no key fits because the question is a one-off analysis over everything, don't Scan the live table: export it to S3 (no read capacity consumed) and query the files with Athena. Query vs Scan has the commands.

When a job must act on every live item (a backfill, a migration), Scan it on purpose: split it across workers with a parallel scan, page it with LastEvaluatedKey (pagination), and pace it.

The full list of when a Scan is fine lives on the Query vs Scan page.

Write the keyed query, not a filter

When you need a condition beyond the key, build it deliberately rather than dumping everything into a FilterExpression.

The DynamoDB Expression Builder generates the KeyConditionExpression and attribute placeholders for you, so the partition and sort key do the narrowing before DynamoDB meters the read, not after.

KeyConditionExpression: PK = :tenant AND begins_with(SK, :day)

Filtering strategies compares the four ways to narrow a read and what each one costs.

PartiQL doesn't save you

SELECT * FROM ProductEvents WHERE eventType = 'login_failed' has no partition-key condition, so it compiles straight to a full Scan. It's the same cost in SQL clothing. The * isn't the problem; the missing key is.

AWS's rule: a PartiQL SELECT avoids a full table scan only when its WHERE pins the partition key with = or IN (AWS: PartiQL select). Write the key into the statement:

SELECT * FROM "ProductEvents"
WHERE PK = 'TENANT#acme' AND begins_with(SK, 'TS#2026-06-23')

To make an accidental PartiQL full scan fail, deny it in IAM (a dynamodb:Scan grant is separate, so leave it off roles that shouldn't scan). The dynamodb:FullTableScan condition key is true for a PartiQL SELECT that would scan the whole table (AWS: IAM policies with PartiQL):

{
  "Effect": "Deny",
  "Action": ["dynamodb:PartiQLSelect"],
  "Resource": [
    "arn:aws:dynamodb:us-east-1:123456789012:table/ProductEvents",
    "arn:aws:dynamodb:us-east-1:123456789012:table/ProductEvents/index/*"
  ],
  "Condition": {"Bool": {"dynamodb:FullTableScan": ["true"]}}
}

Keyed SELECTs still run under the role's Allow; only the full scans fail.

For a GROUP BY, a JOIN or an aggregate DynamoDB can't express, DynoTable's SQL Workbench computes the result on your machine.

Give its base table a partition-key condition and it reads with a Query; without one it still Scans that table, and its status bar says which before you run.

Next steps

Estimate what either pattern costs with the pricing calculator, read Query vs Scan for the API-level contrast, and download DynoTable to run these against your own tables and watch how many items each approach actually reads.

By Dmitriy · Updated