DynamoDB — cannot specify projection when Select is COUNT

TL;DR — Your Query/Scan set Select: COUNT and a ProjectionExpression (or the legacy AttributesToGet). COUNT returns only the number of matching items, never the items themselves, so naming attributes to return is contradictory — DynamoDB rejects it. Pick one: Select: COUNT with no projection, or a projection with Select: SPECIFIC_ATTRIBUTES (the default when you supply a ProjectionExpression).

What it means

ValidationException: 1 validation error detected: Cannot specify the AttributesToGet when choosing to get only the Count

# what the engine actually returns, reproduced against DynamoDB Local:
ValidationException: 1 validation error detected: Cannot specify the ProjectionExpression when choosing to get only the Count

(That's the message with the legacy AttributesToGet parameter; with ProjectionExpression the wording differs, but the rule is the same.) Select controls what a read returns. COUNT asks DynamoDB for a tally (Count/ScannedCount) and no item data. A ProjectionExpression/AttributesToGet asks for specific attributes of returned items. Those two are mutually exclusive — the Query API reference spells it out: "If you use the ProjectionExpression parameter, then the value for Select can only be SPECIFIC_ATTRIBUTES. Any other value for Select will return an error." One cost note: COUNT still consumes the same read capacity as actually fetching the items — it saves bandwidth, not RCUs.

Why it happens

  • Both parameters set at onceSelect: COUNT left in place while a ProjectionExpression was added (or vice versa).
  • Legacy AttributesToGet combined with Select: COUNT.
  • A query builder that always attaches a projection, even when the caller only wanted a count.
  • Misunderstanding Select — expecting COUNT to also hand back the items it counted.

How to fix it

  1. Just counting? Drop the projection. Set Select: COUNT and remove ProjectionExpression/AttributesToGet.
  2. Need specific attributes? Drop Select: COUNT. Supply a ProjectionExpression; DynamoDB defaults Select to SPECIFIC_ATTRIBUTES, so you usually don't set Select at all.
  3. Need both the count and the items? Make one call for the items (with your projection) and read its Count, or make a separate Select: COUNT call.
  4. Prefer ProjectionExpression over AttributesToGet — AWS marks AttributesToGet as a legacy parameter and recommends ProjectionExpression instead.

Open it in DynoTable

DynoTable's query panel separates count mode from projection — you either fetch items with selected attributes or read the matched count, never both in one conflicting request. Open a table with ⌘K, run a Query, and check the result count in the status bar without attaching a ProjectionExpression.

Use the Query Builder to generate a projection-only or count-only request for your SDK code. Switch profiles with ⌘P; configure them under Settings → Profiles with Test Connection. See Connect to AWS and Install.

Sources

References

Last verified 2026-07-13 against the official AWS documentation linked above.

Work with DynamoDB without the Console

A fast DynamoDB desktop client that runs the real SQL DynamoDB can’t — JOINs, GROUP BY, aggregates — with visual editing and an AI agent on your own Bedrock keys.

Free 30-day trial, no credit card — then the Free plan with no time limit.