Question: How to count rows in DynamoDB?

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Answer
Use DescribeTable for an approximate item count, or a paginated Scan with Select: "COUNT" to count the items read. In DynamoDB, an item is the equivalent of a row; having several attributes does not make it several rows.
For a quick inventory count:
aws dynamodb describe-table --table-name Orders --query 'Table.ItemCount' --output text
AWS updates this metadata approximately every six hours, so it is unsuitable for a live business counter. It does not scan the table.
For an evaluated count, request Select: "COUNT" on each Scan page and add its Count. Continue with ExclusiveStartKey until LastEvaluatedKey is absent. ScannedCount counts items examined before filtering; Count counts the ones left after a filter. COUNT avoids returning item bodies but does not reduce read-capacity consumption.
Even a strongly consistent Scan does not provide a table-wide snapshot. If items change during pagination, the total may not represent the table at one instant. For repeatable historical reporting, count a point-in-time export. For frequent application counts, maintain a counter with carefully designed transactional or idempotent updates.
To count only one partition-key range, use Query with COUNT instead of scanning unrelated data. See pagination and Scan vs Query.
Source: AWS Scan API.
Other Common DynamoDB FAQ (with Answers)
- Can DynamoDB have nested objects?
- How to import data from S3 to DynamoDB?
- Can a DynamoDB range key be a GSI key?
- How do you handle empty strings in DynamoDB?
- How do you access DynamoDB from an Android app?
- How do I create an ID in DynamoDB?
- Does DynamoDB support load balancing?
- What are the naming conventions in DynamoDB?
- Will I be charged for an inactive DynamoDB table?
- Can you rename a DynamoDB table?
- Can I use a UUID as a DynamoDB partition key?
- What are the key differences between DynamoDB and Neo4j?
- Is a DynamoDB table Region-specific?
- Can you store lists in DynamoDB?
- Which programming language works best with DynamoDB?
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today