Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

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?

  1. A
    Execute a Scan operation on the table and use a FilterExpression to retrieve only the items matching the target VehicleID and Timestamp range.
  2. Perform a Query operation specifying the VehicleID in the KeyConditionExpression and a range condition for the Timestamp sort key.Cevap
  3. C
    Execute a parallel Scan operation by dividing the table into segments to speed up retrieval of the specific vehicle's telemetry logs.
  4. D
    Initialize 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

1
Identify the primary key structure of the Amazon DynamoDB table.
The table partition key is VehicleID and the sort key is Timestamp.
Knowing the primary key structure determines which DynamoDB API operations (Query vs. Scan) are available for targeted lookups.
2
Evaluate the retrieval requirement against the API options.
The request asks for all logs for a specific VehicleID (partition key) within a specific Timestamp (sort key) range.
Since the partition key is known and the sort key is constrained, a Query operation is the most efficient choice because it performs a direct lookup and only reads matching items.
3
Avoid inefficient patterns (Scan) and insecure credential practices.
Scan operations read the entire table and waste read capacity, while hardcoding AWS access keys violates standard credential chain practices.
Filtering out these bad practices leaves the Query operation with standard credential provider chain usage as the correct choice.

Anahtar Kavram

Using Query instead of Scan for partition-key-based lookups in Amazon DynamoDB
Tahmini Süre:1m 30s
Bu soruyu puanla