AWS Certified Developer – Associate (DVA-C02) — Question 369
A developer manages an application that writes customer orders to an Amazon DynamoDB table. The orders use customer_id as the partition key, order_id as the sort key, and order_date as an attribute. A new access pattern requires accessing data by order_date and order_id. The developer needs to implement a new AWS Lambda function to support the new access pattern.
How should the developer support the new access pattern in the MOST operationally efficient way?
Answer options
- A. Add a new local secondary index (LSI) to the DynamoDB table that specifies order_date as the partition key and order_id as the sort key. Write the new Lambda function to query the new LSI index.
- B. Write the new Lambda function to scan the DynamoDB table. In the Lambda function, write a method to retrieve and combine results by order_date and order_id.
- C. Add a new global secondary index (GSI) to the DynamoDB table that specifies order_date as the partition key and order_id as the sort key. Write the new Lambda function to query the new GSI index.
- D. Enable DynamoDB Streams on the table. Choose the new and old images information to write to the DynamoDB stream. Write the new Lambda function to query the DynamoDB stream
Correct answer: C
Explanation
Creating a Global Secondary Index (GSI) is the most efficient solution because it allows querying the table using a different partition key (order_date) and sort key (order_id) than the base table. Local Secondary Indexes (LSIs) are not viable here because they must use the same partition key as the base table and can only be defined during table creation. Scanning the entire table is highly inefficient and expensive, while DynamoDB Streams are meant for tracking item-level changes rather than serving as a queryable data source.