What is the main purpose of a Local Secondary Index (LSI) in DynamoDB?
Think about how LSI relates to the partition key and sort key in DynamoDB.
An LSI lets you query the table using the same partition key but a different sort key, enabling more flexible queries without duplicating data.
Given a DynamoDB table with partition key UserID and sort key Timestamp, and an LSI with the same partition key UserID but alternate sort key OrderStatus, what will the following query return?
Query on LSI where UserID = '123' and OrderStatus = 'Pending'
Remember that LSI uses the same partition key but a different sort key.
The query on the LSI filters items by the same partition key and the alternate sort key, returning only matching items.
Which of the following JSON snippets correctly defines a Local Secondary Index (LSI) when creating a DynamoDB table?
LSI must use the same partition key as the base table and a different sort key.
Option A correctly defines an LSI with the same partition key UserID and a different sort key OrderStatus. Other options either swap keys or miss the partition key.
You have a DynamoDB table with a partition key CustomerID and sort key OrderDate. You want to efficiently query all orders by CustomerID filtered by OrderStatus. Which approach optimizes query performance?
Think about how LSI shares the partition key and allows alternate sort keys for efficient queries.
Using an LSI with the same partition key and alternate sort key OrderStatus allows efficient queries filtered by status without scanning the whole table.
You created a DynamoDB table with an LSI. When writing new items, you receive a ValidationException error stating: "The total size of indexed attributes exceeds the maximum allowed for LSI." What is the cause of this error?
Check DynamoDB limits on LSI indexed attribute sizes per partition key.
DynamoDB limits the total size of all indexed attributes projected into an LSI to 10 GB per partition key. Exceeding this causes the error.