Which index will provide the FASTEST response for this query?
A global secondary index (GSI) with Product ID as the partition key and Product Rating as the sort key
A global secondary index (GSI) with Product ID as the partition key and Review ID as the sort key
A local secondary index (LSI) with Product ID as the partition key and Product Rating as the sort key
A local secondary index (LSI) with Review ID as the partition key and Product ID as the sort key
Explanations:
A global secondary index (GSI) with Product ID as the partition key and Product Rating as the sort key allows for efficient querying of reviews based on Product ID. This setup enables sorting by Product Rating, making it fast to retrieve the top 10 reviews with the highest ratings for a specific product.
A global secondary index (GSI) with Product ID as the partition key and Review ID as the sort key does not optimize for finding the highest-rated reviews. The sort key of Review ID does not allow for sorting or filtering by Product Rating, which is necessary for this query.
A local secondary index (LSI) with Product ID as the partition key and Product Rating as the sort key is not valid because LSIs share the same partition key as the base table. Since the base table’s partition key is the Review ID, using Product ID as the partition key for the LSI is not allowed.
A local secondary index (LSI) with Review ID as the partition key and Product ID as the sort key does not address the query requirement effectively. This configuration does not facilitate querying reviews by Product ID to find the top ratings, making it inefficient for the desired query.