When I scan one of our tables, including all fields, with a DynamoDB limit of 1000, I get approx 480 items per scan because each item is large enough that the DynamoDB truncates the response based on the 1MB size limit.
However, when I scan the same table, and request only the Primary Key field using ProjectionExpression
, I still only get approx 480 items, which suggests DynamoDB is unnecessarily loading full data from each item, only to discard that data except the Primary key, instead of just pulling keys straight from the primary index.
How do I scan only the Primary index without causing DynamoDB to read the full items, causing DynamoDB to use (and charge me for) unnecessary read capacity?
Query
API instead ofScan
? From AWS documentation: The query operation finds items based on primary key values. You can query any table or secondary index that has a composite primary key (a partition key and a sort key). URL: docs.aws.amazon.com/amazondynamodb/latest/APIReference/… – krishna_mee2004