How to Improve DynamoDB Query Performance for Non-Key Attributes?

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?

  1. Increase the page size for each request by setting the Limit parameter to be higher than the default value. Configure the application to retry any request that exceeds the provisioned throughput.
  2. Create a global secondary index (GSI). Set query attribute to be the partition key of the index. Source Reference Answer
  3. Perform a parallel scan operation by issuing individual scan requests. In the parameters, specify the segment for the scan requests and the total number of segments for the parallel scan.
  4. Turn on read capacity auto scaling for the DynamoDB table. Increase the maximum read capacity units (RCUs).

Community Votes

B
100%

100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

The exam tests your understanding of DynamoDB's key-based access patterns; queries on attributes that are not partition/sort keys require a GSI to avoid full table scans.

Learn why creating a global secondary index (GSI) is the recommended AWS solution for DynamoDB queries on non-key attributes, and how it scales as data grows. Community consensus strongly favors GSI over scan or capacity scaling options.

Choosing option C (parallel scan) or option D (read capacity scaling) is common because they appear to improve performance, but they increase cost/complexity and do not solve the underlying issue of querying a non-key attribute. Instead, a GSI creates a new index with the queried attribute as the partition key, enabling efficient query operations.

Community Discussion (6 comments)

tgv 👍 10 Selected: B
Creating a GSI would be more cost efficient than increasing the RCU in this case.
albert_kuo 👍 1 Selected: B
an attribute that is not the table's partition key or sort key => create GSI to solve this problem
tomchandler077 👍 3
To improve the performance of queries that involve an attribute that is neither the table's partition key nor sort key, and anticipating an increase in data volume, the most effective solution is to utilize a global secondary index (GSI). This allows for efficient querying based on different attributes that are critical for performance but not originally designed as keys in the main table structure.
65703c1 👍 1 Selected: B
B is the correct answer.
be1dca8 👍 2
B Parallel scan operations can be useful for scanning large tables, but they may not necessarily improve performance for specific queries involving non-key attributes.
nder 👍 2 Selected: B
GSI :)

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

Option B is correct because DynamoDB queries require a partition key and optional sort key. When an attribute is neither a table key nor a sort key, a full table scan is needed. A global secondary index (GSI) lets you define a different partition key (and sort key) for the same data, allowing efficient queries on that attribute. As the table grows, the GSI scales independently and keeps query latency low.

Community comments highlight this directly: one comment notes that creating a GSI is more cost-efficient than increasing RCUs, and another explains that the GSI enables efficient querying based on attributes not originally designed as keys.

Why the Other Options Are Wrong

Option A (increasing page size and retrying) only affects how many items are returned in a single request; it does not change the underlying scan/query behavior. It also may cause throttling and does not help with non-key attribute searches.

Option C (parallel scan) can speed up full-table scans, but it still scans every item in the table, which becomes increasingly expensive and slow as data volume grows. It is not a targeted query solution.

Option D (read capacity auto scaling) improves throughput but does not address the fundamental inefficiency of scanning the entire table. Additionally, comments note that GSI is more cost-efficient than simply raising RCUs.

Community Comment Notes

Comment [1] (10 likes) correctly states that creating a GSI is more cost-efficient than increasing RCUs. Comment [2] (3 likes) gives a detailed explanation of why a GSI is the best solution for non-key attribute queries. Comment [3] (2 likes) correctly points out that parallel scans may not improve performance for specific queries involving non-key attributes. Comments [4], [5], and [6] all agree with B, reinforcing the consensus.

Official Reference

Exam Strategy

When you see a DynamoDB question about querying an attribute that is not a table key, immediately consider a global secondary index (GSI). Distinguish between query (efficient, uses key/index) and scan (full table read). Choose GSI over scan or capacity scaling because it directly optimizes the access pattern and scales with data growth.

Related Analysis

Practice All DVA-C02 Questions

Access 100 questions with complete answers and detailed explanations.

View Full DVA-C02 Practice Test →

← Back to DVA-C02 Study Guide