An application uses a DynamoDB table with attributes: partNumber (partition key), vendor (sort key), description, productFamily, and productType. Some modules frequently query for lists of products by productFamily and productType. Which change will improve query performance for those access patterns?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a global secondary index (GSI) with productFamily as the partition key and productType as the sort key..
Why this is the answer
A Global Secondary Index (GSI) is the correct choice because it allows you to query on attributes that are not part of the table's primary key. Here, productFamily and productType are not the primary key attributes, and a GSI can have a different partition key and sort key from the base table. This enables efficient queries for products based on productFamily and productType. A Local Secondary Index (LSI) must share the same partition key as the base table, which is partNumber in this case. Since the desired query pattern is on productFamily and productType, an LSI would not be suitable. Recreating the table with an LSI using productFamily as the partition key is incorrect because an LSI must use the base table's partition key (partNumber). Using Scan operations is inefficient as it reads every item in the table and then filters, leading to high latency and cost, especially for large tables.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed