0
0
DynamoDBquery~20 mins

LSI vs GSI comparison in DynamoDB - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
DynamoDB Index Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Primary difference between LSI and GSI
Which statement correctly describes the primary difference between a Local Secondary Index (LSI) and a Global Secondary Index (GSI) in DynamoDB?
ALSI can have a different partition key than the base table, but GSI must share the same partition key.
BLSI shares the same partition key as the base table, while GSI can have a different partition key.
CBoth LSI and GSI must share the same partition key and sort key as the base table.
DLSI and GSI are identical in structure and usage.
Attempts:
2 left
💡 Hint
Think about how the partition key is used in each index type.
query_result
intermediate
2:00remaining
Query behavior difference between LSI and GSI
Given a DynamoDB table with both an LSI and a GSI, which query will always require specifying the partition key value?
AQuerying the LSI requires specifying the partition key value.
BQuerying the GSI requires specifying the partition key value.
CNeither LSI nor GSI require specifying the partition key value.
DBoth LSI and GSI queries do not require partition key values.
Attempts:
2 left
💡 Hint
Consider how partition keys are used in queries for LSIs.
📝 Syntax
advanced
2:30remaining
Correct syntax to create an LSI
Which option shows the correct syntax snippet to define a Local Secondary Index (LSI) in a DynamoDB table creation using AWS CLI JSON format?
A{ "IndexName": "MyLSI", "KeySchema": [{"AttributeName": "UserId", "KeyType": "HASH"}, {"AttributeName": "Timestamp", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"} }
B{ "IndexName": "MyLSI", "KeySchema": [{"AttributeName": "Timestamp", "KeyType": "HASH"}, {"AttributeName": "UserId", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"} }
C{ "IndexName": "MyLSI", "KeySchema": [{"AttributeName": "UserId", "KeyType": "RANGE"}, {"AttributeName": "Timestamp", "KeyType": "HASH"}], "Projection": {"ProjectionType": "ALL"} }
D{ "IndexName": "MyLSI", "KeySchema": [{"AttributeName": "Timestamp", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"} }
Attempts:
2 left
💡 Hint
LSI must use the same partition key as the base table as HASH key.
optimization
advanced
2:00remaining
Choosing between LSI and GSI for query flexibility
You want to query a DynamoDB table by multiple different partition keys and sort keys not defined in the base table. Which index type should you choose to maximize query flexibility?
ALocal Secondary Index (LSI)
BNeither, use only the base table keys
CBoth LSI and GSI equally support different partition keys
DGlobal Secondary Index (GSI)
Attempts:
2 left
💡 Hint
Think about which index allows a different partition key from the base table.
🔧 Debug
expert
2:30remaining
Why does this LSI creation fail?
You try to create a DynamoDB table with an LSI where the LSI's partition key is different from the base table's partition key. What error will you encounter?
AProvisionedThroughputExceededException: Throughput limit exceeded.
BResourceInUseException: Table already exists.
CValidationException: Local Secondary Index partition key must be the same as the base table partition key.
DConditionalCheckFailedException: Condition check failed.
Attempts:
2 left
💡 Hint
LSI partition key must match base table partition key exactly.