Error: DynamoDB scan does not return all items

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
Scan does not return the whole table in one response. Each call evaluates up to 1 MB of data or the requested Limit, then applies filters. Continue with LastEvaluatedKey until it is absent or empty; raising Limit does not remove the page-size boundary.
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, ScanCommand } from "@aws-sdk/lib-dynamodb";
const db = DynamoDBDocumentClient.from(new DynamoDBClient({ region: "us-east-1" }));
let cursor;
do {
const page = await db.send(new ScanCommand({
TableName: "Orders", ExclusiveStartKey: cursor
}));
for (const item of page.Items ?? []) console.log(item);
cursor = page.LastEvaluatedKey;
} while (cursor && Object.keys(cursor).length);Remove or correct a filter if you intended every item. For a parallel Scan, finish every segment and keep each segment’s cursor separate. Scanning a sparse GSI will not include base-table items that lack its keys.
A scan is not a transactionally consistent snapshot, even with ConsistentRead=true. Concurrent changes can affect what you observe. For repeated application reads, use a key-based Query where possible; for a point-in-time dataset, consider an export workflow instead.
See Scan pagination and AWS documentation.
Other Common DynamoDB Errors (with Solutions)
- dynamodb index does not exist
- dynamodb-admin is not recognized as an internal or external command
- DynamoDB Key element does not match the schema
- dynamodb scan missing values
- DynamoDB stream not working
- DynamoDB throttling error
- dynamodb-admin command not found
- ProvisionedThroughputExceededException DynamoDB
- DynamoDB local error unable to access JAR file dynamodblocal.jar
- dynamodb list_append if_not_exists not working
- DynamoDB ConditionalCheckFailedException
- could not lookup table in dynamodb
- dynamodb ttl not deleting / erasing items
- dynamodb query not returning the full item
- accessdeniedexception dynamodb
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today