Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is building a corporate timesheet application where employee hours are stored in an Amazon DynamoDB table. The table uses `EmployeeID` as the partition key and `LogDate` as the sort key. The application needs to retrieve and display a list of all work logs for a specific employee during the month of June 2026. The operation must be optimized to minimize latency and Read Capacity Unit (RCU) consumption.

Which DynamoDB configuration and operation should the developer use to retrieve this data?

  1. Perform a Query operation using the KeyConditionExpression parameter to specify both the EmployeeID partition key and a range condition on the LogDate sort key.Cevap
  2. B
    Perform a Query operation using the KeyConditionExpression parameter to specify the EmployeeID partition key, and apply a FilterExpression to filter the LogDate range.
  3. C
    Perform a Scan operation using the FilterExpression parameter to specify both the EmployeeID partition key and the LogDate range.
  4. D
    Perform a Scan operation with a ProjectionExpression to limit the returned attributes to EmployeeID and LogDate, then filter the logs on the client side.

Cevap

Perform a Query operation using the KeyConditionExpression parameter to specify both the EmployeeID partition key and a range condition on the LogDate sort key.
The correct option is the one suggesting a Query operation with KeyConditionExpression for both the partition and sort keys. In DynamoDB, a Query operation finds items based on primary key values. By specifying both the partition key (EmployeeID) and a range condition on the sort key (LogDate) in the KeyConditionExpression, DynamoDB only reads the items that match both conditions. This minimizes the number of items read from physical storage, resulting in low latency and minimal Read Capacity Unit (RCU) consumption.

Adım Adım Çözüm

1
Analyze the table schema and retrieval requirements.
The table has a composite primary key: partition key (EmployeeID) and sort key (LogDate). The goal is to retrieve items for one specific employee within a specific date range (June 2026).
Understanding the primary key structure allows us to determine if we can use a Query instead of a Scan.
2
Evaluate Query vs. Scan operations.
A Scan reads the entire table. A Query searches only the specific partition associated with the EmployeeID.
Since the partition key (EmployeeID) is known, Query is the correct and most cost-effective operation.
3
Determine the optimal way to filter the sort key (LogDate).
Using KeyConditionExpression for both EmployeeID and LogDate filters items before reading. Using a FilterExpression filters them after reading, which consumes unnecessary RCUs.
To minimize RCU consumption, the sort key range must be defined inside KeyConditionExpression.

Anahtar Kavram

DynamoDB Query operations and RCU optimization via KeyConditionExpression
Bu soruyu puanla