Get All Items from DynamoDB in Python (boto3)

Reading a whole table in boto3 means paginating a scan to the end. Each response caps at 1 MB, and the low-level client's built-in paginator follows LastEvaluatedKey across every page for you (how DynamoDB cursors work).

Which boto3 API you pick matters more here than the pagination does, and the paginator is only half the reason.

Code

import boto3

client = boto3.client("dynamodb")

paginator = client.get_paginator("scan")

items = []
for page in paginator.paginate(TableName="Music"):
    items.extend(page["Items"])

print(f"Table holds {len(items)} items")

Explanation

  • Paginators belong to the client, not the resourceboto3.resource("dynamodb").Table(…).scan has no paginator at all, so there you write the LastEvaluatedKey loop yourself. That alone is a good reason to use the low-level client for a full read.
  • The resource API converts numbers to Decimal — a stored {"N": "1994"} comes back as Decimal('1994'), which json.dumps refuses to serialise without a custom encoder. The client above hands you the raw {"N": "1994"} and leaves the conversion to you (the encoding).
  • Tune the paginator instead of replacing itpaginator.paginate(TableName="Music", PaginationConfig={"PageSize": 500, "MaxItems": 10000}). Boto3 defines PageSize as "the number of items returned per page of each result" and MaxItems as a cap on the total, which emits a NextToken you resume from with StartingToken.
  • Parallel scans need one client per thread, built carefullySegment and TotalSegments split the work, and boto3's own guidance is that clients are thread-safe while sessions and resources are not. It also warns that "Invoking boto3.client() inside of a concurrent context may result in response ordering issues". Build the client before you fan out, or give each worker its own boto3.session.Session() (when parallel is worth it).
  • items grows to the size of the table — handle each page inside the loop rather than extending a list you keep, unless you already know the table is small.
  • A scan bills every byte it reads, on every runProjectionExpression shrinks the response and not the bill (why); a FilterExpression drops items after they are read and charged (Scan with a filter). On a hot path you want a query.

Do it visually

A full scan's bill is item size times item count, rounded up in 4 KB units. The item size calculator gives you the per-item half of that from a pasted item.

DynoTable pages through a live table in an infinite-scrolling grid instead, and its SQL editor names the operation your query compiles to before you run it. The RCU estimate appears only when table metadata supports it. Download DynoTable.

References

Last verified 2026-07-28 against the official AWS documentation linked above.

Build this request visually

Compose this operation in the free DynamoDB Query Builder — key condition, filter, index, Limit, sort order, and a pagination loop — and copy it back as a runnable SDK v3, CLI, or boto3 program.

Open the DynamoDB Query Builder

Work with DynamoDB without the Console

A fast DynamoDB desktop client that runs the real SQL DynamoDB can’t — JOINs, GROUP BY, aggregates — with visual editing and an AI agent on your own Bedrock keys.

Free 30-day trial, no credit card — then the Free plan with no time limit.