AWS Certified Developer – Associate — Question 275

A company has an ecommerce application. To track product reviews, the company's development team uses an Amazon DynamoDB table.

Every record includes the following:

• A Review ID, a 16-digit universally unique identifier (UUID)
• A Product ID and User ID, 16-digit UUIDs that reference other tables
• A Product Rating on a scale of 1-5
• An optional comment from the user

The table partition key is the Review ID. The most performed query against the table is to find the 10 reviews with the highest rating for a given product.

Which index will provide the FASTEST response for this query?

Answer options

Correct answer: A

Explanation

To query by Product ID, a Global Secondary Index (GSI) is required because Local Secondary Indexes (LSIs) must share the same partition key as the base table (Review ID). By defining a GSI with Product ID as the partition key and Product Rating as the sort key, DynamoDB can directly locate and sort the reviews for a given product by their rating. This allows the application to retrieve the top 10 highest-rated reviews in a single, highly efficient query operation.