Development with AWS Services1 / 5
A developer is implementing a DynamoDB query for a table with a composite primary key (partition key: UserId, sort key: Timestamp). The developer wants to retrieve all items for a specific user where the timestamp is between two dates. Which approach should the developer use?
CorrectIncorrect
Alex
For a table with a composite primary key, Query requires partition-key equality and can include a sort-key condition such as BETWEEN, begins_with, greater than, or less than. In this case, UserId is the partition key and Timestamp is the sort key, so querying a user between two timestamps belongs in the KeyConditionExpression. Scan is inefficient for known partition-key access, and FilterExpression is not a substitute for a key condition because filtering happens after DynamoDB reads the matching item set.
Sourcedocs.aws.amazon.com
Follow-up answers are available in the app. Create a free account — no credit card required.
Question 1 of 5
Create a free account