A developer is building a mobile shopping application that stores product details in an Amazon DynamoDB table. The application currently retrieves products belonging to a specific department by performing a Scan operation on the base table and filtering the results using a FilterExpression on the Department attribute. This is causing high latency and excessive Read Capacity Unit (RCU) consumption. Which two actions should the developer take to retrieve the products efficiently while minimizing RCU consumption? (Select TWO.)
- Create a Global Secondary Index (GSI) with Department as the partition key.Cevap
- Use the Query API operation on the GSI to retrieve the products.Cevap
- CUse a Scan operation with a FilterExpression to filter products by their department on the server side.
- DUse a ProjectionExpression in the Scan operation to only retrieve items matching the department.
- EConfigure the DynamoDB client by hardcoding AWS access keys inside the application initialization code to bypass authorization overhead.
Cevap
Create a Global Secondary Index (GSI) with Department as the partition key, and use the Query API operation on the GSI to retrieve the products.
To optimize the read operations and minimize Read Capacity Unit (RCU) consumption, the developer should create a Global Secondary Index (GSI) using the Department attribute as the partition key, and then use the Query API operation instead of Scan. The Query operation only reads the items that share the target partition key, significantly reducing the RCU footprint compared to a full Scan.
Adım Adım Çözüm
Anahtar Kavram
DynamoDB Query vs Scan optimization using Global Secondary Indexes (GSIs)