How to Efficiently Filter DynamoDB Records by Non-Key Attribute?
Short answer
D Create a global secondary index (GSI) with OrderSource as the partition key. Perform a Query operation by using MobileApp as the key.
Question
Key Takeaways
Tests efficient querying of non-key attributes via GSIs, with the common trap being confusion between partition and sort key roles in index design.
This scenario evaluates optimal data modeling for filtering non-partition-key attributes using Global Secondary Indexes, with strong community consensus favoring partition-based queries over scans or sort-key-only designs.
Common mistake: Option C is frequently chosen because candidates misunderstand how DynamoDB indexes work, incorrectly assuming that placing the filter attribute as a sort key alone enables efficient partition-level lookups without specifying a partition key value.
Expert Analysis
Why the Answer Is Correct
Creating a Global Secondary Index (GSI) with OrderSource as the partition key enables direct, highly efficient Query operations. Since the table contains over 100,000 records, a partition-based lookup guarantees logarithmic time complexity and minimal read capacity consumption. This approach isolates the target items to a single partition, delivering consistent sub-millisecond latency that significantly enhances user experience. The AWS documentation explicitly recommends this pattern for accessing data through alternative access paths.
Why the Other Options Are Wrong
Option A triggers a full table Scan, which reads every item regardless of the filter condition, causing excessive latency and high costs. Option B proposes a Local Secondary Index (LSI), but LSIs must share the base table’s partition key (OrderID), making it impossible to use OrderSource as the primary lookup attribute. Option C places OrderSource as a sort key, but a Query operation still requires a valid partition key value to locate data, rendering it ineffective for direct attribute-based filtering. These alternatives fail to provide the deterministic routing necessary for scalable application performance.
Community Comment Notes
Candidate discussions highlight confusion regarding index key placement, with some users incorrectly advocating for sort-key-only configurations due to perceived uniqueness benefits. As noted in the top-voted comments, candidates who selected option C misunderstood how DynamoDB resolves secondary index lookups without a partition key qualifier. Reviewers consistently emphasize that exam scenarios prioritize predictable read patterns over theoretical indexing flexibility. Aligning your mental model with AWS-recommended access patterns will prevent similar pitfalls.
Official Reference
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SecondaryIndexes.html
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-indexes-general-primary-secondary.html
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html
These links open the official vendor documentation in a new tab.
Exam Strategy
When designing for specific access patterns, always map your most frequent query filters directly to a GSI partition key rather than relying on sort keys or full-table scans. Prioritize operations that allow deterministic routing to a single partition to ensure consistent sub-millisecond latency.
Community Votes
83% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 3 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 3
-
aws_god 👍 1 Answered CYou should add the OrderSource as the sort key, only the OrderID is unique should be set as the partition key to give the best performance
-
Skip 👍 1Going for B, feel free to comment. I think these comments sections help me a lot!
-
Alagong 👍 5 Answered DAnswer : D
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →