You have a DynamoDB table with a sparse global secondary index (GSI) on attribute status. Only items with status set appear in the index.
What will the following query on the GSI return?
Query on GSI where status = 'active'
Remember, a sparse index only contains items where the indexed attribute exists.
A sparse index in DynamoDB only includes items that have the indexed attribute. Querying the GSI with status = 'active' returns only those items with that status.
What is the main advantage of using a sparse index in DynamoDB?
Think about what happens when only some items have the indexed attribute.
Sparse indexes only include items with the indexed attribute, so they are smaller and cheaper to query than full indexes.
Which of the following GSI definitions correctly creates a sparse index on attribute category?
A sparse index requires the indexed attribute as the partition key (HASH).
To create a sparse index, the GSI must have the attribute as the HASH key. Option A correctly sets category as HASH key with full projection.
You want to efficiently query only items with a priority attribute set to 'high'. Which approach best uses a sparse index?
Sparse indexes only include items with the indexed attribute as partition key.
Using priority as the partition key in a GSI creates a sparse index that contains only items with that attribute, making queries efficient.
You created a sparse GSI on attribute region. You query the GSI for region = 'us-east-1' but get no results, even though items with that region exist in the table.
What is the most likely cause?
Check if the attribute values exactly match the GSI key attribute.
If the attribute values differ in case or type, or are missing, the sparse index will not include those items, causing queries to return no results.