Development with AWS Services

A DynamoDB table uses customerId as its partition key and orderTime as its sort key. How should a developer retrieve one customer's orders within a time range with the least read capacity consumption?

Show the answer

Correct answerA. Query with customerId and orderTime in a key condition

AWhy this is right: The key condition restricts reads to the customer and the required sort key range.

BWhy not this: Scan reads across the table before applying the filter, consuming capacity for unrelated orders.

CWhy not this: The filter discards out-of-range orders only after they have consumed read capacity.

DWhy not this: Scan still reads across the table; a projection does not restrict which items are read.

A Query can use partition key equality and a sort key range to read only matching orders. Filtering orderTime after reading the customer's items consumes capacity for items that the filter discards.