Question #882
A company's application uses Amazon DynamoDB and is experiencing high latency for queries that filter on an attribute not part of the table's partition key or sort key. The data volume is expected to grow rapidly, and the developer needs a cost-effective solution to optimize query performance. Which approach should the developer take?
Adjust the ProjectionExpression parameter to include only necessary attributes. Configure the application to handle throttling errors by implementing exponential backoff.
Create a global secondary index (GSI) with the filtered attribute as the partition key. Design the application to query the GSI instead of the base table.
Use a distributed scan operation by dividing the table into segments and scanning them concurrently. Increase the number of worker threads handling the scans.
Enable write capacity auto scaling for the DynamoDB table. Set a higher baseline read capacity to accommodate future growth.
Explanation
The correct answer is B. DynamoDB queries require the partition key (and optionally the sort key) for efficient access. Filtering on non-key attributes forces DynamoDB to scan the entire table, which is slow and costly, especially with large datasets. A GSI creates a separate index with the filtered attribute as the partition key, enabling fast queries directly on that attribute. This avoids full table scans and scales efficiently.
Other options are incorrect because:
- A: ProjectionExpression reduces returned data but doesn't optimize query performance.
- C: Scans are inherently inefficient and costly, even when parallelized.
- D: Auto scaling addresses throughput, not query latency caused by inefficient access patterns.
Answer
The correct answer is: B