nerdexam
Amazon

DVA-C02 · Question #630

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 OrderlD as the partition key and there is no sort key. The…

The correct answer is D. Create a global secondary index (GSI) with OrderSource as the partition key. Perform a Query. Querying 100,000+ DynamoDB records by a non-key attribute requires a Global Secondary Index (GSI) with that attribute as the partition key to avoid full-table scans.

Submitted by manish99· Mar 5, 2026Refactoring

Question

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 OrderlD 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?

Options

  • APerform a Scan operation on the Orders table. Provide a QueryFilter condition to filter to only the
  • BCreate a local secondary index (LSI) with OrderSource as the partition key. Perform a Query
  • CCreate a global secondary index (GSI) with OrderSource as the sort key. Perform a Query
  • DCreate a global secondary index (GSI) with OrderSource as the partition key. Perform a Query

How the community answered

(35 responses)
  • A
    17% (6)
  • B
    9% (3)
  • C
    6% (2)
  • D
    69% (24)

Why each option

Querying 100,000+ DynamoDB records by a non-key attribute requires a Global Secondary Index (GSI) with that attribute as the partition key to avoid full-table scans.

APerform a Scan operation on the Orders table. Provide a QueryFilter condition to filter to only the

A Scan operation reads every item in the table regardless of the filter, which is highly inefficient and expensive for 100,000+ records and does not scale with data growth.

BCreate a local secondary index (LSI) with OrderSource as the partition key. Perform a Query

A Local Secondary Index (LSI) must share the same partition key (OrderID) as the base table, so it cannot be used to query across all orders by OrderSource alone without knowing the OrderID.

CCreate a global secondary index (GSI) with OrderSource as the sort key. Perform a Query

A GSI with OrderSource as the sort key still requires specifying a partition key value to query, making it unsuitable for retrieving all records matching an OrderSource value across the full dataset.

DCreate a global secondary index (GSI) with OrderSource as the partition key. Perform a QueryCorrect

A GSI with OrderSource as the partition key allows efficient Query operations that retrieve only matching records directly without scanning the full table; queries on a GSI partition key are O(1) lookups rather than O(n) scans, making this the most efficient approach for large datasets.

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.

Full DVA-C02 Practice