A developer is optimization-tuning an e-commerce order processing system. The order data is stored in an Amazon DynamoDB table where the primary key consists of (partition key) and (sort key). The application frequently retrieves all orders placed by a specific user within a given date range. Currently, the application retrieves this data by performing a Scan operation with a FilterExpression on the and attributes, which has caused high latency and read capacity exhaustion. Which two actions should the developer take to resolve these issues? (Select TWO.)
- Create a Global Secondary Index (GSI) with UserId as the partition key and OrderDate as the sort key.Answer
- Configure the application to perform Query operations against the newly created Global Secondary Index using UserId as the key condition.Answer
- CModify the application to perform a parallel Scan on the base table using a Segment parameter to divide the workload.
- DIncrease the provisioned read capacity units (RCUs) of the base table to prevent read throttling during peak Scan requests.
- EHardcode an IAM user's Access Key and Secret Key with DynamoDBFullAccess permissions in the application configuration to ensure scan requests never fail due to authorization issues.
Answer
Create a Global Secondary Index (GSI) with UserId as the partition key and OrderDate as the sort key, and configure the application to perform Query operations against the GSI using UserId as the key condition.
The correct approach involves creating a Global Secondary Index (GSI) that designates the search attribute as the partition key and the range attribute as the sort key, and then updating the application to run targeted Query operations on this index. This eliminates the need to scan the entire base table, reducing both latency and Read Capacity Unit (RCU) consumption.
Step-by-Step Solution
Key Concept
Optimizing DynamoDB data retrieval by replacing table scans with targeted queries on a Global Secondary Index (GSI).