0
0
DynamoDBquery~20 mins

Local Secondary Index (LSI) concept in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
LSI Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the purpose of Local Secondary Index (LSI)

What is the main purpose of a Local Secondary Index (LSI) in DynamoDB?

ATo replicate data across multiple regions automatically
BTo create a global index that spans all partitions with a different partition key
CTo allow querying data using an alternate sort key while keeping the same partition key
DTo increase the write throughput capacity of the table
Attempts:
2 left
💡 Hint

Think about how LSI relates to the partition key and sort key in DynamoDB.

query_result
intermediate
2:00remaining
Query result using LSI with alternate sort key

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'
ANo items because LSI cannot be queried
BAll items with UserID '123' regardless of OrderStatus
CAll items with OrderStatus 'Pending' regardless of UserID
DAll items with UserID '123' and OrderStatus 'Pending'
Attempts:
2 left
💡 Hint

Remember that LSI uses the same partition key but a different sort key.

📝 Syntax
advanced
2:00remaining
Identify the correct syntax to create an LSI

Which of the following JSON snippets correctly defines a Local Secondary Index (LSI) when creating a DynamoDB table?

A{ "IndexName": "StatusIndex", "KeySchema": [{"AttributeName": "UserID", "KeyType": "HASH"}, {"AttributeName": "OrderStatus", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"} }
B{ "IndexName": "StatusIndex", "KeySchema": [{"AttributeName": "OrderStatus", "KeyType": "HASH"}, {"AttributeName": "UserID", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"} }
C{ "IndexName": "StatusIndex", "KeySchema": [{"AttributeName": "UserID", "KeyType": "HASH"}], "Projection": {"ProjectionType": "ALL"} }
D{ "IndexName": "StatusIndex", "KeySchema": [{"AttributeName": "OrderStatus", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"} }
Attempts:
2 left
💡 Hint

LSI must use the same partition key as the base table and a different sort key.

optimization
advanced
2:00remaining
Choosing LSI for query performance optimization

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?

ACreate a Local Secondary Index with partition key <code>CustomerID</code> and sort key <code>OrderStatus</code>
BCreate a Global Secondary Index with partition key <code>OrderStatus</code> and sort key <code>CustomerID</code>
CScan the entire table and filter results by <code>OrderStatus</code>
DAdd <code>OrderStatus</code> as a new attribute but do not index it
Attempts:
2 left
💡 Hint

Think about how LSI shares the partition key and allows alternate sort keys for efficient queries.

🔧 Debug
expert
2:00remaining
Diagnosing LSI write capacity error

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?

AThe combined size of the base table item and all indexed attributes for the LSI exceeds 10 GB limit
BThe total size of all indexed attributes projected into the LSI exceeds 10 GB per partition key
CThe total size of all indexed attributes projected into the LSI exceeds 10 MB per partition key
Dyek noititrap rep BG 01 sdeecxe ISL eht otni detcejorp setubirtta dexedni lla fo ezis latot ehT
Attempts:
2 left
💡 Hint

Check DynamoDB limits on LSI indexed attribute sizes per partition key.