A developer is building a medical monitoring application that stores periodic heart rate readings from wearable sensors in an Amazon DynamoDB table. The table uses `DeviceID` as the partition key and `Timestamp` as the sort key. The developer needs to retrieve all heart rate readings for a specific device that are greater than within a specific -hour window. Which two actions should the developer take to achieve this requirement?
- Perform a `Query` operation on the table using the `DeviceID` and `Timestamp` in the key condition expression.Cevap
- BPerform a `Scan` operation on the table, using a filter expression on `DeviceID` and `Timestamp`.
- Use a `FilterExpression` in the `Query` operation to return only the records with a heart rate greater than .Cevap
- DHardcode an IAM user's access keys directly in the AWS SDK client initialization code to bypass any read authorization latency.
- EPerform a `Scan` operation on a newly created Global Secondary Index (GSI) that has the heart rate as the partition key.
Cevap
To retrieve the heart rate data efficiently, the developer should perform a `Query` operation on the table using the `DeviceID` and `Timestamp` in the key condition expression, and use a `FilterExpression` in the `Query` operation to return only the records with a heart rate greater than .
To retrieve data efficiently from DynamoDB, the developer should use the `Query` operation. By specifying the partition key (`DeviceID`) and the sort key (`Timestamp`) in the key condition expression, the query only reads the items that belong to that specific device and time window. Because heart rate is a non-key attribute, a filter expression is used to discard items that do not meet the criteria (greater than ) before the response is returned to the client, which reduces network utilization.
Adım Adım Çözüm
Anahtar Kavram
Optimizing DynamoDB retrieval using Query operations and FilterExpressions instead of full table Scans, and following secure credential management.