Hint: Limit caps items; LastEvaluatedKey true means more pages [OK]
Common Mistakes:
Assuming all items returned ignoring Limit
Thinking LastEvaluatedKey is false when present
Expecting error without ExclusiveStartKey
4. You wrote this code to paginate DynamoDB scan results but it returns only the first page repeatedly:
let params = { TableName: 'Users', Limit: 3 };
let data;
do {
data = await dynamoDbClient.scan(params);
console.log(data.Items);
} while (data.LastEvaluatedKey);
What is the main issue?
medium
A. Missing update of ExclusiveStartKey in params inside the loop.
B. Limit should be increased to fetch all items.
C. The loop condition should check data.Items instead.
D. The scan method does not support pagination.
Solution
Step 1: Analyze loop behavior
The code calls scan repeatedly but never updates ExclusiveStartKey, so it fetches the same first page each time.
Step 2: Identify correct fix
To get next pages, params.ExclusiveStartKey must be set to data.LastEvaluatedKey inside the loop.
Final Answer:
Missing update of ExclusiveStartKey in params inside the loop. -> Option A
Quick Check:
Update ExclusiveStartKey to paginate [OK]
Hint: Update ExclusiveStartKey each loop to get next page [OK]
Common Mistakes:
Not updating ExclusiveStartKey inside loop
Increasing Limit instead of paginating
Wrong loop condition on Items
Thinking scan can't paginate
5. You want to fetch all items from a large DynamoDB table using pagination with the SDK. Which approach correctly handles this scenario?
hard
A. Use a loop that calls scan with Limit, updating ExclusiveStartKey each time until LastEvaluatedKey is undefined.
B. Call scan once with a very large Limit to get all items at once.
C. Use scan without Limit and stop when Items array is empty.
D. Call scan repeatedly without ExclusiveStartKey until Items length is zero.
Solution
Step 1: Understand DynamoDB pagination for large tables
Large tables require multiple scan calls with a Limit to avoid timeouts and memory issues.
Step 2: Correctly implement pagination loop
Each scan call should use ExclusiveStartKey from the previous LastEvaluatedKey until it is undefined, indicating no more pages.
Final Answer:
Use a loop that calls scan with Limit, updating ExclusiveStartKey each time until LastEvaluatedKey is undefined. -> Option A
Quick Check:
Loop with Limit and ExclusiveStartKey until done [OK]
Hint: Loop with Limit and ExclusiveStartKey until no LastEvaluatedKey [OK]
Common Mistakes:
Using huge Limit causing timeouts
Ignoring ExclusiveStartKey for next pages
Stopping on empty Items instead of LastEvaluatedKey
Calling scan repeatedly without pagination
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.