How should the developer support the new access pattern in the MOST operationally efficient way?
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.
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.
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.
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
Explanations:
A local secondary index (LSI) requires the same partition key as the base table. Sinceorder_dateis not the partition key in the original table structure, an LSI cannot be created usingorder_dateas the partition key. Therefore, this option is not valid for supporting the new access pattern.
Scanning the DynamoDB table is inefficient for large datasets, as it reads all items and applies filters after the fact. This method can lead to high latency and cost, especially if the table grows. This approach does not utilize indexes, which are designed to optimize access patterns.
A global secondary index (GSI) allows for a different partition key and sort key than those defined in the main table. Adding a GSI withorder_dateas the partition key andorder_idas the sort key supports the new access pattern efficiently, enabling quick queries without scanning the entire table.
Enabling DynamoDB Streams allows for tracking changes in the table, but it does not support the new access pattern directly. The Lambda function querying the stream would not provide direct access to order data byorder_dateandorder_id, making this option inefficient for the intended access pattern.