A developer is designing a mobile fitness application that stores daily step counts in an Amazon DynamoDB table. The table has as the partition key and as the sort key. The developer needs to retrieve all step counts for a specific user over the past month.
Which DynamoDB operation should the developer use to retrieve this data in the most efficient manner?
- AUse the Scan operation with a filter expression specifying the .
- BUse the Scan operation and filter the retrieved items on the client side.
- Use the Query operation with a key condition expression specifying the .Cevap
- DUse a parallel Scan operation with multiple segments to find the user's records.
Cevap
Use the Query operation with a key condition expression specifying the UserId.
The Query operation is the most efficient way to retrieve items because it targets only the partition associated with the specified partition key value. In this scenario, specifying the UserId in a key condition expression allows DynamoDB to read only the items for that user, minimizing Read Capacity Unit (RCU) consumption.
Adım Adım Çözüm
Anahtar Kavram
Using the Query operation instead of the Scan operation to retrieve items with a known partition key in Amazon DynamoDB.