Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is designing a vehicle tracking system where telemetry data is written to an Amazon DynamoDB table. Each item contains VehicleID (partition key), Timestamp (sort key), Speed, FuelLevel, and GeoLocation. The application needs to retrieve telemetry records for a specific vehicle within a specific 2424-hour window where the vehicle's speed exceeds 80 km/h80\text{ km/h}, while minimizing read latency and resource consumption. Which two actions should the developer take to achieve this?

  1. Perform a Query operation specifying the VehicleID in the KeyConditionExpression and a range condition on Timestamp.Cevap
  2. Apply a FilterExpression in the Query operation to filter the retrieved records by the speed attribute before returning them.Cevap
  3. C
    Perform a Scan operation with a FilterExpression containing the VehicleID, Timestamp, and speed attributes.
  4. D
    Increase the provisioned read capacity units (RCUs) of the table to mitigate throttling errors caused by high-volume queries on a single vehicle ID.
  5. E
    Initialize the DynamoDB client by hardcoding temporary AWS credentials directly in the application code to minimize authentication overhead.

Cevap

Perform a Query operation specifying the VehicleID in the KeyConditionExpression and a range condition on Timestamp, and apply a FilterExpression in the Query operation to filter the retrieved records by the speed attribute before returning them.
To retrieve records for a specific partition key (VehicleID) and a range of sort keys (Timestamp) efficiently, a Query operation should be used. The KeyConditionExpression specifies the partition key equality and the sort key range. To filter the returned items by a non-key attribute (Speed), a FilterExpression is applied. This filters the data on the server side before returning it to the client, minimizing the payload size.

Adım Adım Çözüm

1
Analyze the table schema and the query requirements to determine the optimal access pattern.
Identified VehicleID as the partition key and Timestamp as the sort key. Telemetry needs to be retrieved for a specific vehicle over a specific 2424-hour range.
This matches the structure required for a Query operation where partition key is an exact match and sort key can be a range.
2
Choose between a Query and a Scan operation for item retrieval.
Selected Query because it performs direct lookups using the key attributes, whereas Scan checks every item in the table.
Query consumes fewer Read Capacity Units (RCUs) and provides lower latency compared to Scan.
3
Determine how to handle the non-key attribute filter (Speed > 80 km/h80\text{ km/h}).
Applied a FilterExpression to the Query operation.
Since speed is not a key attribute, a FilterExpression is used to filter out non-matching items on the server side after they are read, minimizing the payload returned to the application.

Anahtar Kavram

Using Query operations with KeyConditionExpression and FilterExpression to optimize data retrieval in Amazon DynamoDB
Bu soruyu puanla