A developer is building a personal finance application that tracks user transactions. The transactions are stored in an Amazon DynamoDB table with AccountID as the partition key and TransactionTimestamp as the sort key. A dashboard needs to display all transactions for a specific account that are categorized as 'Entertainment' to analyze spending habits. The developer wants to retrieve this data with the lowest latency and minimal Read Capacity Unit (RCU) consumption. Which two strategies should the developer implement to meet these requirements? (Choose two.)
- Create a Global Secondary Index (GSI) with AccountID as the partition key and Category as the sort key, then use the Query API on the GSI.Answer
- Configure the GSI projection to include only the required attributes needed for the dashboard, such as TransactionTimestamp and Amount.Answer
- CPerform a Scan operation on the base table using a FilterExpression to return only the transactions where Category is equal to 'Entertainment'.
- DPerform a parallel Scan operation across the table using segments to speed up the retrieval of the 'Entertainment' transactions.
- EConfigure the AWS SDK client inside the application code with hardcoded IAM User access keys to bypass IAM role assumption latency.
Answer
To optimize the data retrieval, the developer should create a Global Secondary Index (GSI) with AccountID as the partition key and Category as the sort key, querying this index directly. Furthermore, the GSI should project only the required attributes needed for the dashboard instead of all attributes to minimize RCU consumption.
To achieve the lowest latency and minimal RCU consumption, the developer should create a Global Secondary Index (GSI) with AccountID as the partition key and Category as the sort key. This allows the application to run targeted Query operations directly on the index instead of scanning. To optimize performance and cost further, the GSI projection should be limited to only the required attributes needed for the dashboard, which minimizes the amount of data transferred and read capacity consumed.
Step-by-Step Solution
Key Concept
Optimizing DynamoDB queries and read throughput using Global Secondary Indexes (GSIs) and projection attributes.