A developer is building a fleet monitoring application that tracks delivery vehicle telemetry. The application stores telemetry data in an Amazon DynamoDB table with `VehicleID` as the partition key and `Timestamp` as the sort key. The table contains millions of records spanning thousands of unique vehicles. The application needs to retrieve all telemetry logs for a specific vehicle within a given 24-hour window. Which of the following is the most efficient and cost-effective approach to retrieve this data?
- AExecute a Scan operation on the table and use a FilterExpression to retrieve only the items matching the target VehicleID and Timestamp range.
- Perform a Query operation specifying the VehicleID in the KeyConditionExpression and a range condition for the Timestamp sort key.Cevap
- CExecute a parallel Scan operation by dividing the table into segments to speed up retrieval of the specific vehicle's telemetry logs.
- DInitialize the AWS SDK DynamoDB client by passing hardcoded IAM access keys directly into the client initialization code, and then execute a Query operation.
Cevap
Perform a Query operation specifying the VehicleID in the KeyConditionExpression and a range condition for the Timestamp sort key.
Performing a Query operation is the most efficient and cost-effective method because it uses the partition key (VehicleID) to narrow the search to a single partition, and the sort key (Timestamp) condition to fetch only the relevant records. This reads only the requested items, minimizing Read Capacity Unit (RCU) consumption.
Adım Adım Çözüm
Anahtar Kavram
Using Query instead of Scan for partition-key-based lookups in Amazon DynamoDB
Tahmini Süre:1m 30s