dynobase-icon
Dynobase

Error: DynamoDB sorting is not supported for scan expressions

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

DynamoDB Scan does not support sorting results. ScanIndexForward belongs to Query and cannot order a Scan. For ordered access, query a table or index whose sort key represents the desired ordering, within the specified partition-key value.

const params = {
  TableName: "Orders",
  KeyConditionExpression: "pk = :pk",
  ExpressionAttributeValues: { ":pk": "CUSTOMER#123" },
  ScanIndexForward: false
};
// Use SDK v3 QueryCommand with DynamoDBDocumentClient.
// This table's sort key must encode the intended ordering.

Query returns ascending sort-key order by default; false reverses it. Numeric sort keys sort numerically, while string sort keys follow UTF-8 byte order. An index can support another ordering, but it does not provide an unrestricted globally sorted table scan.

For small datasets, collect every Scan page and sort the complete result in application memory. Sorting each page independently does not produce a globally sorted result. For large analytical datasets, export or replicate to an appropriate query engine rather than repeatedly scanning and sorting the live table.

See sort-key design 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.