What should the developer do to meet these requirements in the MOST operationally efficient manner?
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.
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.
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.
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.
Explanations:
Creating a new global secondary index (GSI) with theUserNameas the partition key andTotalReactionsOnBlogsas the sort key allows efficient querying for the top 10 customers with the most reactions. It does not affect the existing table’s read capacity and ensures that the read operations are efficient without consuming the primary table’s read capacity.
A local secondary index (LSI) requires that the partition key be the same as the base table’s partition key. This would not allow querying based onTotalReactionsOnBlogsindependently, as the partition key in the LSI would beUserNameand the sort key would still need to beNumberOfBlogs, which is not optimal for this use case.
Backing up and restoring the table to a new DynamoDB table with a new GSI would require significant operational overhead, and this method involves deleting the original table. This adds complexity and is not as efficient as modifying the existing table with a GSI.
Backing up and restoring the table to a new DynamoDB table with an LSI would not work since LSIs are limited by the same partition key as the base table, making it unsuitable for efficiently querying based onTotalReactionsOnBlogs. Also, deleting the original table adds unnecessary complexity.