You wrote a query with KeyConditionExpression 'PK = :pk and SK > :sk' but get an error. What is a likely cause?
medium📝 Debug Q6 of 15
DynamoDB - Access Patterns and Query Optimization
You wrote a query with KeyConditionExpression 'PK = :pk and SK > :sk' but get an error. What is a likely cause?
AUsing a greater than operator on the sort key is invalid
BThe query must use begins_with instead of >
CThe partition key value :pk is missing or incorrect
DThe sort key attribute is not defined in the table
Step-by-Step Solution
Solution:
Step 1: Check KeyConditionExpression requirements
Partition key must be specified exactly in a query; missing or wrong value causes errors.
Step 2: Evaluate options
The partition key value :pk is missing or incorrect is likely because without a valid partition key, the query fails. Using a greater than operator on the sort key is invalid is false; > is valid on sort key. The sort key attribute is not defined in the table would cause different errors. The query must use begins_with instead of > is incorrect; > is allowed.
Final Answer:
The partition key value :pk is missing or incorrect -> Option C
Quick Check:
Partition key required and correct = D [OK]
Quick Trick:Partition key must be exact and present in query [OK]
Common Mistakes:
MISTAKES
Using > on partition key
Omitting partition key value
Confusing query with scan
Master "Access Patterns and Query Optimization" in DynamoDB
9 interactive learning modes - each teaches the same concept differently