Bird
0
0

You wrote this DynamoDB Scan command but it is very slow:

medium📝 Debug Q14 of 15
AWS - DynamoDB
You wrote this DynamoDB Scan command but it is very slow:
aws dynamodb scan --table-name Users

What is the best way to improve performance if you only want users with UserId = '123'?
AReplace Scan with Query using KeyConditionExpression on UserId
BAdd a FilterExpression to the Scan command
CIncrease the Read Capacity Units of the table
DUse UpdateItem to modify the UserId
Step-by-Step Solution
Solution:
  1. Step 1: Identify problem with Scan

    Scan reads all items, causing slowness when filtering after reading.
  2. Step 2: Use Query for known key

    Query with KeyConditionExpression on UserId reads only matching items, improving speed.
  3. Final Answer:

    Replace Scan with Query using KeyConditionExpression on UserId -> Option A
  4. Quick Check:

    Known key = Query, not Scan [OK]
Quick Trick: Use Query with key condition, not Scan with filter [OK]
Common Mistakes:
  • Adding filter to Scan instead of using Query
  • Increasing capacity without optimizing query
  • Using UpdateItem unrelated to read performance

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes