A developer is building a product catalog application where items are stored in an Amazon DynamoDB table. The developer wants to retrieve specific product items based on their category while keeping the read latency and consumption of Read Capacity Units (RCUs) as low as possible. Which of the following strategies should the developer implement to achieve this goal? (Select TWO.)
- Use the Query API operation instead of the Scan API operation to retrieve items.Answer
- Create a Global Secondary Index (GSI) with the product category as the partition key if it is not the partition key of the base table.Answer
- CUse the Scan API operation and apply a FilterExpression to return only the products matching the specific category.
- DHardcode AWS access keys directly in the application's SDK client configuration to ensure immediate authentication and bypass credential retrieval latency.
- EIncrease the table's provisioned read capacity units whenever a ProvisionedThroughputExceededException occurs, without analyzing partition key distribution.
Answer
To optimize DynamoDB operations, the developer should use the Query API operation instead of the Scan API operation, and create a Global Secondary Index (GSI) with the product category as the partition key if it is not the partition key of the base table.
Using the Query operation directly targets the relevant partition and retrieves only the matching items, minimizing RCU usage. Additionally, defining a Global Secondary Index (GSI) with the category as the partition key enables the Query operation even when the category is not the base table's partition key.
Step-by-Step Solution
Key Concept
Optimizing DynamoDB reads using Query operations and Secondary Indexes instead of Scans.
Estimated Time:1m 0s