DVA-C03 practice question: DynamoDB queries, scans and capacity
Development with AWS Services A free question from our original DVA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
It runs a Query on the Tickets table with partition key CustomerId and a FilterExpression that keeps only items where Status is open, and it sets Limit to 25. The code reads only the first response.
Agents report that customers with hundreds of tickets are shown only a few open tickets, or none. The team wants every open ticket returned, and it wants the query to stay on the one customer's partition.
What should the developer change?
Choose one answer.
AA. Keep the Query, and loop on ExclusiveStartKey using each response's LastEvaluatedKey until that key is absent.
BB. Remove the FilterExpression, and filter the open tickets in the application from the first response alone.
CC. Raise Limit to 1,000 so that each response can hold more of the customer's open tickets before the code stops reading.
DD. Replace the Query with a Scan that uses the same FilterExpression, since a scan is not limited to one partition key value.
B. Wrong: The first response is still only one page of at most 1 MB, so later pages would be missed. Filtering in the application also moves more data across the network.
C. Wrong: Limit caps how many items are read per page, and the page is still capped at 1 MB. A page can still contain no open tickets at all.
D. Wrong: A scan is paginated in the same way, and it reads every partition. It would be slower and cost more, and it would not stay on one customer.
Explanation
DynamoDB returns at most 1 MB per request, and Limit and the page cap are applied before the FilterExpression. A page can therefore contain no matching items and still carry a LastEvaluatedKey. The code must keep requesting pages until LastEvaluatedKey is absent.
Want more on DynamoDB queries, scans and capacity? The 5 full-length practice sets have 8 more DynamoDB queries, scans and capacity questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →