dynobase-icon
Dynobase

Error: DynamoDB Query Limit Not Working

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

DynamoDB Query Limit caps items evaluated before FilterExpression, not the number of matching items returned. With Limit set to 10, DynamoDB may return fewer than 10 matches, including zero, and still supply LastEvaluatedKey.

Continue from that key until enough matches are collected or no continuation key remains. For example, with the v3 document client db and QueryCommand:

const matches = [];
let key;
const wanted = 10;
do {
  const page = await db.send(new QueryCommand({
    TableName: "Orders",
    KeyConditionExpression: "pk = :pk",
    FilterExpression: "#status = :status",
    ExpressionAttributeNames: { "#status": "status" },
    ExpressionAttributeValues: { ":pk": "CUSTOMER#123", ":status": "OPEN" },
    Limit: wanted - matches.length,
    ExclusiveStartKey: key,
  }));
  matches.push(...(page.Items ?? []));
  key = page.LastEvaluatedKey;
} while (matches.length < wanted && key && Object.keys(key).length > 0);

The service page-size boundary can stop a request before Limit is reached. Preserve the final continuation key if the user can request another page. SDK paginators and the AWS CLI may automatically fetch multiple service pages, so their page-size setting is not necessarily a total-result cap. Filtering many pages to find a few items can be expensive; consider an index matching the access pattern.

See pagination examples and AWS documentation.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Changelog
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.