AWS Certified Developer – Associate — Question 289
A company has an application that provides blog hosting services to its customers. The application includes an Amazon DynamoDB table with a primary key. The primary key consists of the customers’ UserName as a partition key and the NumberOfBlogs as a sort key. The application stores the TotalReactionsOnBlogs as an attribute on the same DynamoDB table.
A developer needs to implement an operation to retrieve the top 10 customers based on the greatest number of reactions on their blogs. This operation must not consume the DynamoDB table’s existing read capacity.
What should the developer do to meet these requirements in the MOST operationally efficient manner?
Answer options
- A. For the existing DynamoDB table, create a new global secondary index (GSI) that has the UserName as a partition key and the TotalReactionsOnBlogs as a sort key.
- B. For the existing DynamoDB table, create a new local secondary index (LSI) that has the UserName as a partition key and the TotalReactionsOnBlogs as a sort key.
- C. Back up and restore the DynamoDB table to a new DynamoDB table. Create a new global secondary index (GSI) that has the UserName as a partition key and the TotalReactionsOnBlogs as a sort key. Delete the old DynamoDB table.
- D. Back up and restore the DynamoDB table to a new DynamoDB table. Create a new local secondary index (LSI) that has the UserName as a partition key and the TotalReactionsOnBlogs as a sort key. Delete the old DynamoDB table.
Correct answer: A
Explanation
Global secondary indexes (GSIs) can be added to an existing DynamoDB table at any time and feature their own dedicated read/write capacity, ensuring queries on the GSI do not deplete the base table's read capacity. In contrast, local secondary indexes (LSIs) can only be defined during table creation and share the base table's capacity units. Therefore, creating a GSI directly on the existing table is the most operationally efficient approach, making backup and restore operations unnecessary.