Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A logistics company uses an Amazon DynamoDB table to store tracking updates for shipments. The table uses ShipmentID as the partition key and Timestamp as the sort key. The application needs to retrieve all tracking updates for a specific ShipmentID that occurred within a given 48-hour window. The table contains millions of items representing shipments from the last year. How should the developer implement this retrieval to optimize read throughput and minimize latency?

  1. Perform a Query operation specifying the ShipmentID in the KeyConditionExpression and a range condition on the Timestamp sort key.Cevap
  2. B
    Perform a Scan operation on the table and apply a FilterExpression on ShipmentID and Timestamp to filter out the undesired shipments and dates.
  3. C
    Perform a parallel Scan operation using segments to divide the table, and filter the returned items using the application code.
  4. D
    Initialize the DynamoDB client by embedding an IAM User's access key and secret key directly in the client configuration, and execute a Scan operation.

Cevap

Perform a Query operation specifying the ShipmentID in the KeyConditionExpression and a range condition on the Timestamp sort key.
Performing a Query operation specifying the ShipmentID in the KeyConditionExpression and a range condition on the Timestamp sort key is the most efficient method. A Query directly locates the items using the partition key index and filters them based on the sort key range, consuming Read Capacity Units (RCUs) only for the returned items.

Adım Adım Çözüm

1
Identify the primary key structure of the DynamoDB table.
The table has a composite primary key consisting of ShipmentID (partition key) and Timestamp (sort key).
Understanding the key structure is necessary to determine if a Query operation is possible.
2
Evaluate the retrieval requirements against DynamoDB read operations.
The requirement is to fetch items for a specific partition key (ShipmentID) and a range of the sort key (Timestamp).
DynamoDB Query operations allow querying a specific partition key with optional sort key conditions, which matches the requirements.
3
Choose the most efficient operation and configuration.
Select a Query operation rather than a Scan, using KeyConditionExpression to specify both partition key and sort key conditions.
Query only consumes Read Capacity Units (RCUs) for the items read, whereas Scan reads the entire table, making Query far more efficient and lower latency.

Anahtar Kavram

Query vs Scan operations and key design in DynamoDB
Tahmini Süre:1m 30s
Bu soruyu puanla