Global Secondary Indexes in Azure Cosmos DB

A cross-partition query happens when the partition key is not included in your Azure Cosmos DB query. Without the partition key, Azure Cosmos DB cannot determine the location of the data you’re searching for, which means it will execute the query across all database servers. As you might expect, this can lead to issues with both the cost and performance of the query.

To address the issue of cross-partition queries, you may be creating Materialized Views with the Change Feed feature of Azure Cosmos DB. When a change occurs in the source database, the Change Feed triggers an Azure Function, which then transfers the data to a different container that has a different partition key.

Global Secondary Indexes improve the stability and user-friendliness of the manual process creating Materialized Views. They allow you to easily select specific documents or properties by using a filter option defined by a SELECT statement. These Global Secondary Indexes are read-only index containers that each have their own settings, including Partition Key, Indexes, and Request Units (RU). You can define multiple Global Secondary Index containers for a standard container.

Check out my following video to see them in action.


Leave a Reply

Your email address will not be published. Required fields are marked *