Question

Difficulty: HardData Store Operations with Amazon DynamoDB

A developer is optimizing a reporting dashboard for a logistics application. The application tracks shipment updates in an Amazon DynamoDB table with ShipmentIDShipmentID as the partition key and TimestampTimestamp as the sort key. The dashboard needs to retrieve all shipments that are currently in 'Delayed' status and have a weight exceeding 100100 kg. This query must run efficiently across millions of shipments. Which two actions should the developer take to retrieve this data with the lowest latency and minimal Read Capacity Unit (RCU) consumption? (Select TWO.)

  1. Create a Global Secondary Index (GSI) with a partition key of Status and a sort key of Weight.Answer
  2. Perform a Query operation on the new Global Secondary Index using a key condition expression for Status and Weight.Answer
  3. C
    Perform a Scan operation on the base table and apply a FilterExpression for Status and Weight.
  4. D
    Increase the provisioned read capacity units (RCUs) on the base table and execute a parallel scan to distribute the workload.
  5. E
    Initialize the AWS SDK client inside the application code by hardcoding administrative AWS access keys to speed up connection initialization.

Answer

Create a Global Secondary Index (GSI) with a partition key of Status and a sort key of Weight, and perform a Query operation on the new GSI using a key condition expression.
To retrieve the delayed shipments with a weight exceeding 100100 kg efficiently, a Global Secondary Index (GSI) must be created using Status as the partition key and Weight as the sort key. This allows the application to execute a Query operation, which directly targets only the relevant items in the index, minimizing Read Capacity Unit (RCU) consumption and reducing latency.

Step-by-Step Solution

1
Analyze the query requirements.
The query needs to filter on Status (equality comparison) and Weight (range comparison, greater than 100100). The base table's partition key is ShipmentID, which does not allow efficient filtering on these attributes.
Understanding the access pattern is necessary to choose the correct indexing strategy.
2
Design the index structure.
A Global Secondary Index (GSI) is designed with Status as the partition key (to group delayed items) and Weight as the sort key (to enable inequality comparisons on weight).
A GSI allows querying on non-key attributes from the base table.
3
Select the correct DynamoDB API operation.
The Query operation is selected to retrieve matching items from the GSI using a key condition expression.
Query operations are much more efficient than Scan operations as they only read the matching partition and sort keys instead of scanning the entire index/table.

Key Concept

Using Global Secondary Indexes (GSIs) and Query operations instead of Scans to retrieve filtered datasets efficiently.
Rate this question