A developer is optimizing a reporting dashboard for a logistics application. The application tracks shipment updates in an Amazon DynamoDB table with as the partition key and as the sort key. The dashboard needs to retrieve all shipments that are currently in 'Delayed' status and have a weight exceeding 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.)
- Create a Global Secondary Index (GSI) with a partition key of Status and a sort key of Weight.Answer
- Perform a Query operation on the new Global Secondary Index using a key condition expression for Status and Weight.Answer
- CPerform a Scan operation on the base table and apply a FilterExpression for Status and Weight.
- DIncrease the provisioned read capacity units (RCUs) on the base table and execute a parallel scan to distribute the workload.
- EInitialize 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 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
Key Concept
Using Global Secondary Indexes (GSIs) and Query operations instead of Scans to retrieve filtered datasets efficiently.