How to Efficiently Filter DynamoDB Records by Non-Key Attribute?
A developer is working on an app for a company that uses an Amazon DynamoDB table named Orders to store customer orders. The table uses OrderID as the partition key and there is no sort key. The table contains more than 100,000 records. The developer needs to add a functionality that will retrieve all Orders records that contain an OrderSource attribute with the MobileApp value. Which solution will improve the user experience in the MOST efficient way?
Community Votes
83% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
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.
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.
Community Discussion (3 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
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
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.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →