0
0
AWScloud~20 mins

Secondary indexes (GSI, LSI) in AWS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Secondary Indexes Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference between GSI and LSI in DynamoDB

Which statement correctly describes a key difference between a Global Secondary Index (GSI) and a Local Secondary Index (LSI) in DynamoDB?

AA GSI can only be created at table creation, while an LSI can be added anytime after table creation.
BA GSI can have a different partition key than the base table, while an LSI shares the same partition key but has a different sort key.
CBoth GSI and LSI must share the same partition and sort keys as the base table.
DAn LSI can have a different partition key than the base table, while a GSI shares the same partition key but has a different sort key.
Attempts:
2 left
💡 Hint

Think about which index type allows a different partition key from the main table.

Architecture
intermediate
2:00remaining
Choosing index type for query flexibility

You have a DynamoDB table with a partition key 'UserID' and sort key 'OrderDate'. You want to query orders by 'ProductCategory' regardless of user. Which index type should you create?

ACreate a Global Secondary Index with 'ProductCategory' as partition key.
BCreate a Local Secondary Index with 'ProductCategory' as sort key.
CCreate a Local Secondary Index with 'ProductCategory' as partition key.
DCreate a Global Secondary Index with 'UserID' as partition key and 'ProductCategory' as sort key.
Attempts:
2 left
💡 Hint

Remember that LSIs share the same partition key as the base table.

service_behavior
advanced
2:00remaining
Impact of LSI size limit on table design

Your DynamoDB table uses an LSI. What happens if the total size of all items with the same partition key exceeds 10 GB?

ADynamoDB rejects writes that cause the size to exceed 10 GB for that partition key.
BDynamoDB automatically creates a new partition to handle the extra data.
CDynamoDB deletes the oldest items to keep size under 10 GB.
DDynamoDB converts the LSI to a GSI automatically.
Attempts:
2 left
💡 Hint

Consider DynamoDB's hard limits on LSI size per partition key.

security
advanced
2:00remaining
Access control for GSIs in IAM policies

You want to restrict a user to only query a specific Global Secondary Index (GSI) on a DynamoDB table. Which IAM policy condition is required?

AUse the 'dynamodb:PartitionKey' condition key to specify the GSI partition key.
BUse the 'dynamodb:TableName' condition key to specify the GSI name.
CUse the 'dynamodb:Attributes' condition key to specify GSI attributes.
DUse the 'dynamodb:IndexName' condition key to specify the allowed GSI name.
Attempts:
2 left
💡 Hint

Think about which IAM condition key controls access to indexes.

Best Practice
expert
3:00remaining
Optimizing cost and performance with GSIs

You have a DynamoDB table with a GSI that is rarely queried but has high write traffic. What is the best practice to optimize cost and performance?

ARemove the GSI and perform full table scans instead.
BIncrease the provisioned write capacity on the GSI to handle all writes.
CUse sparse indexes by including a GSI partition key attribute only on items that need to be indexed.
DDuplicate the table and use the duplicate for GSI queries.
Attempts:
2 left
💡 Hint

Think about how to reduce unnecessary writes to the GSI.