Exams / DVA-C02 / DynamoDB queries, scans and capacity / Question 1
DVA-C02 practice question: DynamoDB queries, scans and capacity
Development with AWS Services A free question from our original DVA-C02 practice exam. Try it, then open the answer to see why each option is right or wrong.
A developer's code runs a DynamoDB Query for all items with a given partition key. The partition holds several megabytes of data, but the code only ever gets back part of it, and the response includes a LastEvaluatedKey element. How should the developer retrieve all the items?
Choose one answer.
- AA. Increase the Limit parameter until all of the items fit in a single response.
- BB. Replace the Query with a Scan, which has no response size limit.
- CC. Set ConsistentRead to true so DynamoDB returns the complete result.
- DD. Repeat the Query with LastEvaluatedKey as ExclusiveStartKey until it is absent.
Show the answer and explanation
Answer: D
- A. Wrong: Limit can only reduce the number of items read. A single Query page is still capped at 1 MB.
- B. Wrong: Scan pages are capped in the same way, and a scan reads the whole table instead of one partition.
- C. Wrong: Read consistency controls how fresh the data is, not how much of it comes back in one page.
- D. Right: Correct. Each request returns the next page, and a response without LastEvaluatedKey is the last page.
Explanation
DynamoDB paginates Query and Scan results in pages of up to 1 MB. The LastEvaluatedKey in a response marks where the page ended. Passing it as ExclusiveStartKey continues from there, and only its absence means all results have been read. SDK paginators wrap this loop for you.
Study
Keep practising
Answer questions with a score at the end, or practise just this topic with the explanation after each one. No sign-up needed.