How do you count items in DynamoDB?

Use Select: 'COUNT' on a Query or Scan to count matching items without returning them. Each response counts only up to 1 MB scanned, so you must paginate with LastEvaluatedKey and sum the Count values for a full total. For an approximate table total, read ItemCount from DescribeTable.

Counting matched items exactly

Set Select to COUNT on a Query (for one partition key) or Scan (whole table). The response returns Count and ScannedCount but no item data. If the scanned data exceeds 1 MB, the operation stops and returns LastEvaluatedKey — keep calling and adding up Count until it is absent.

Count vs ScannedCount

  • Count — items matching your key/filter conditions in this page.
  • ScannedCount — items examined before filtering. A filter expression narrows results but does not reduce what was scanned (or its cost).

The cheap approximation

DescribeTable returns ItemCount, a table-wide estimate updated roughly every six hours. It is free and instant, but not real-time — good for dashboards, not for exact totals.

Go deeper

Read count, sum, and aggregate in DynamoDB and build count queries with the Expression Builder. Download DynoTable to run counts against your tables.

Console 없이 DynamoDB 작업하기

DynoTable은 DynamoDB를 위한 빠른 데스크톱 클라이언트입니다 — 테이블을 탐색하고, SQL 스타일 쿼리를 실행하고, 항목을 로컬에서 편집하세요.