Bird
0
0

You need to retrieve all items with a specific partition key and a sort key value greater than 1000. Which operation and parameters should you use for best performance?

hard📝 Best Practice Q8 of 15
AWS - DynamoDB
You need to retrieve all items with a specific partition key and a sort key value greater than 1000. Which operation and parameters should you use for best performance?
AQuery with KeyConditionExpression: partitionKey = :pkval AND sortKey > :val
BScan with FilterExpression: partitionKey = :pkval AND sortKey > :val
CScan with KeyConditionExpression: partitionKey = :pkval
DQuery with FilterExpression: partitionKey = :pkval AND sortKey > :val
Step-by-Step Solution
Solution:
  1. Step 1: Use Query for partition key and sort key conditions

    Query supports KeyConditionExpression with partition key and sort key range conditions efficiently.
  2. Step 2: Avoid Scan for performance

    Scan reads entire table and filters after reading, which is inefficient.
  3. Final Answer:

    Query with KeyConditionExpression: partitionKey = :pkval AND sortKey > :val -> Option A
  4. Quick Check:

    Use Query with KeyConditionExpression for key range queries [OK]
Quick Trick: Use Query with KeyConditionExpression for key range filters [OK]
Common Mistakes:
MISTAKES
  • Using Scan for key range queries
  • Using FilterExpression instead of KeyConditionExpression
  • Confusing Query and Scan parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes