DVA-C02 · Question #339
A company runs an application on AWS. The application stores data in an Amazon DynamoDB table. Some queries are taking a long time to run. These slow queries involve an attribute that is not the…
The correct answer is B. Create a global secondary index (GSI). Set query attribute to be the partition key of the index. A Global Secondary Index (GSI) allows efficient queries on non-key attributes by creating a secondary index with the target attribute as its partition key.
Question
A company runs an application on AWS. The application stores data in an Amazon DynamoDB table. Some queries are taking a long time to run. These slow queries involve an attribute that is not the table's partition key or sort key. The amount of data that the application stores in the DynamoDB table is expected to increase significantly. A developer must increase the performance of the queries. Which solution will meet these requirements?
Options
- AIncrease the page size for each request by setting the Limit parameter to be higher than the
- BCreate a global secondary index (GSI). Set query attribute to be the partition key of the index.
- CPerform a parallel scan operation by issuing individual scan requests. In the parameters, specify
- DTurn on read capacity auto scaling for the DynamoDB table. Increase the maximum read capacity
How the community answered
(34 responses)- A3% (1)
- B85% (29)
- C3% (1)
- D9% (3)
Why each option
A Global Secondary Index (GSI) allows efficient queries on non-key attributes by creating a secondary index with the target attribute as its partition key.
Increasing the Limit parameter controls pagination page size but does not change the underlying query mechanism; a scan on a non-key attribute still reads every item in the table.
A GSI lets you define an alternate partition key (and optional sort key) on any attribute, enabling DynamoDB to execute efficient key-based lookups instead of full table scans. Setting the slow-query attribute as the GSI partition key converts an O(n) scan into an O(log n) indexed query, which remains performant as data grows.
A parallel scan distributes scan segments across multiple workers for higher throughput, but it is still a full table scan on a non-key attribute, which becomes slower as data grows.
Read capacity auto scaling adjusts provisioned throughput to prevent throttling but does not change query efficiency; a scan on a non-key attribute still has O(n) complexity.
Concept tested: DynamoDB Global Secondary Index for non-key attribute queries
Source: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html
Community Discussion
No community discussion yet for this question.