Bird
0
0

You want to fetch all items from a large DynamoDB table using pagination with the SDK. Which approach correctly handles this scenario?

hard🚀 Application Q15 of 15
DynamoDB - with AWS SDK
You want to fetch all items from a large DynamoDB table using pagination with the SDK. Which approach correctly handles this scenario?
AUse a loop that calls scan with Limit, updating ExclusiveStartKey each time until LastEvaluatedKey is undefined.
BCall scan once with a very large Limit to get all items at once.
CUse scan without Limit and stop when Items array is empty.
DCall scan repeatedly without ExclusiveStartKey until Items length is zero.
Step-by-Step Solution
Solution:
  1. Step 1: Understand DynamoDB pagination for large tables

    Large tables require multiple scan calls with a Limit to avoid timeouts and memory issues.
  2. Step 2: Correctly implement pagination loop

    Each scan call should use ExclusiveStartKey from the previous LastEvaluatedKey until it is undefined, indicating no more pages.
  3. Final Answer:

    Use a loop that calls scan with Limit, updating ExclusiveStartKey each time until LastEvaluatedKey is undefined. -> Option A
  4. Quick Check:

    Loop with Limit and ExclusiveStartKey until done [OK]
Quick Trick: Loop with Limit and ExclusiveStartKey until no LastEvaluatedKey [OK]
Common Mistakes:
MISTAKES
  • Using huge Limit causing timeouts
  • Ignoring ExclusiveStartKey for next pages
  • Stopping on empty Items instead of LastEvaluatedKey
  • Calling scan repeatedly without pagination

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes