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.

Trabaja con DynamoDB sin la Consola

DynoTable es un cliente de escritorio rápido para DynamoDB: explora tablas, ejecuta consultas estilo SQL y edita Items localmente.