{"id":1013,"date":"2019-09-19T00:00:00","date_gmt":"2019-09-19T07:00:00","guid":{"rendered":"https:\/\/azure.microsoft.com\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db"},"modified":"2025-06-25T12:42:07","modified_gmt":"2025-06-25T19:42:07","slug":"three-ways-to-leverage-composite-indexes-in-azure-cosmos-db","status":"publish","type":"post","link":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/","title":{"rendered":"Three ways to leverage composite indexes in Azure Cosmos DB"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Composite indexes were introduced in Azure Cosmos DB at Microsoft Build 2019. With our latest service update, additional query types can now leverage composite indexes. In this post, we\u2019ll explore composite indexes and highlight common use cases.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"index-types-in-azure-cosmos-db\">Index types in Azure Cosmos DB<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Azure Cosmos DB currently has the following index types that are used for the following types of queries:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Range indexes:<\/b><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Equality queries<\/li>\n\n\n\n<li class=\"wp-block-list-item\">Range queries<\/li>\n\n\n\n<li class=\"wp-block-list-item\">ORDER BY queries on a single property<\/li>\n\n\n\n<li class=\"wp-block-list-item\">JOIN queries<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Spatial indexes:<\/b><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Geospatial functions<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Composite indexes:<\/b><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">ORDER BY queries on multiple properties<\/li>\n\n\n\n<li class=\"wp-block-list-item\">Queries with a filter as well as an ORDER BY clause<\/li>\n\n\n\n<li class=\"wp-block-list-item\">Queries with a filter on two or more properties<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"composite-index-use-cases\">Composite index use cases<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By default, Azure Cosmos DB will create a range index on every property. For many workloads, these indexes are enough, and no further optimizations are necessary. Composite indexes can be added in addition to the default range indexes. Composite indexes have both a path and order (ASC or DESC) defined for each property within the composite index.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"order-by-queries-on-multiple-properties\">ORDER BY queries on multiple properties<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If a query has an ORDER BY clause with two or more properties, a composite index is required. For example, the following query requires a composite index defined on age and name (age ASC, name ASC):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\nSELECT * FROM c ORDER BY c.age ASC, c.name ASC\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">This query will sort all results in ascending order by the value of the age property. If two documents have the same age value, the query will sort the documents by name.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"queries-with-a-filter-as-well-as-an-order-by-clause\">Queries with a filter as well as an ORDER BY clause<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If a query has a filter as well as an ORDER BY clause on different properties, a composite index will improve performance. For example, the following query will require fewer request units (RU\u2019s) if a composite index on name and age is defined and the query is updated to include the name in the ORDER BY clause:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Original query utilizing range index:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\nSELECT * FROM c WHERE c.name = \u201cTim\u201d ORDER BY c.age ASC\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Revised query utilizing a composite index on name and age:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\nSELECT * FROM c WHERE c.name = \u201cTim\u201d ORDER BY c.name ASC, c.age ASC\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">While a composite index will significantly improve query performance, you can still run the original query successfully without a composite index. When you run the revised query with a composite index, it will sort documents by the age property. Since all documents matching the filter have the same name value, the query will return them in ascending order by age.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"queries-with-a-filter-on-multiple-properties\">Queries with a filter on multiple properties<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If a query has a filter with two or more properties, adding a composite index will improve performance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Consider the following query:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\nSELECT * FROM c WHERE c.name = \u201cTim\u201d and c.age > 18\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">In the absence of a composite index on (name ASC, and age ASC), we will utilize a range index for this query. We can improve the efficiency of this query by creating a composite index for name and age.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Queries with multiple equality filters and a maximum of one range filter (such as &gt;,&lt;, &lt;=, &gt;=, !=) will utilize the composite index. In some cases, if a query can\u2019t fully utilize a composite index, it will use a combination of the defined composite indexes and range indexes. For more information, reference our <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/index-policy\">indexing policy documentation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"composite-index-performance-benefits\">Composite index performance benefits<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We can run some sample queries to highlight the performance benefits of composite indexes. We will use a <a href=\"https:\/\/github.com\/CosmosDB\/labs\/tree\/master\/dotnet\/setup\/NutritionData.json\">nutrition dataset<\/a> that is used in <a href=\"https:\/\/cosmosdb.github.io\/labs\/\">Azure Cosmos DB labs<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, we will optimize a query that has a filter as well as an ORDER BY clause. We will start with the default indexing policy which indexes all properties with a range index. Executing the following query as referenced in the image below in the Azure Portal, we observe the query metrics:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Query metrics:<\/p>\n\n\n\n<figure class=\"wp-block-image has-custom-border\"><img decoding=\"async\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp\" alt=\"Query which uses range index and consumes 21.8 RU\u00e2\u20ac\u2122s.\" style=\"border-radius:0px\" title=\"\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This query, with the default indexing policy, required 21.8 RU\u2019s.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Adding a composite index on foodGroup and _ts and updating the query text to include foodGroup in the ORDER BY clause significantly reduced the query\u2019s RU charge.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Query metrics:<\/p>\n\n\n\n<figure class=\"wp-block-image has-custom-border\"><img decoding=\"async\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/b1f0825d-7f42-4dc8-80a3-482b0e30ee87.webp\" alt=\"Query which uses composite index and consumes 4.07 RU\u00e2\u20ac\u2122s.\" style=\"border-radius:0px\" title=\"\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After adding a composite index, the query\u2019s RU charge decreased from 21.8 RU\u2019s to only 4.07 RU\u2019s. This query optimization will be particularly impactful as the total data size increases. The benefits of a composite index are significant when the properties in the ORDER BY clause have a high cardinality.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-composite-indexes\">Creating composite indexes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can learn more about <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/how-to-manage-indexing-policy\">creating composite indexes<\/a> in this documentation. It\u2019s simple to update the indexing policy directly through the Azure Portal. While creating a composite index for data that\u2019s already in Azure Cosmos DB, the index update will utilize the RU\u2019s leftover from normal operations. After the new indexing policy is defined, Azure Cosmos DB will automatically index properties with a composite index as they\u2019re written.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Explore whether composite indexes will improve RU utilization for your existing workloads on <a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/cosmos-db\/\">Azure Cosmos DB<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Composite indexes were introduced in Azure Cosmos DB at Microsoft Build 2019. With our latest service update, additional query types can now leverage composite indexes.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ms_queue_id":[],"ep_exclude_from_search":false,"_classifai_error":"","_classifai_text_to_speech_error":"","_alt_title":"","footnotes":"","msx_community_cta_settings":[]},"categories":[1473,1485],"tags":[],"audience":[3057,3055,3056],"content-type":[1511],"product":[1538],"tech-community":[],"topic":[],"coauthors":[97],"class_list":["post-1013","post","type-post","status-publish","format-standard","hentry","category-databases","category-internet-of-things","audience-data-professionals","audience-developers","audience-it-implementors","content-type-best-practices","product-azure-cosmos-db","review-flag-1680286581-56","review-flag-4-1680286581-250","review-flag-8-1680286581-263","review-flag-lever-1680286579-649","review-flag-new-1680286579-546"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Three ways to leverage composite indexes in Azure Cosmos DB | Microsoft Azure Blog<\/title>\n<meta name=\"description\" content=\"Composite indexes were introduced in Azure Cosmos DB at Microsoft Build 2019. With our latest service update, additional query types can now leverage composite indexes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Three ways to leverage composite indexes in Azure Cosmos DB | Microsoft Azure Blog\" \/>\n<meta property=\"og:description\" content=\"Composite indexes were introduced in Azure Cosmos DB at Microsoft Build 2019. With our latest service update, additional query types can now leverage composite indexes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft Azure Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/microsoftazure\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-19T07:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-25T19:42:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp\" \/>\n<meta name=\"author\" content=\"Microsoft Azure\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@azure\" \/>\n<meta name=\"twitter:site\" content=\"@azure\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Microsoft Azure\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/\"},\"author\":[{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/microsoft-azure\/\",\"@type\":\"Person\",\"@name\":\"Microsoft Azure\"}],\"headline\":\"Three ways to leverage composite indexes in Azure Cosmos DB\",\"datePublished\":\"2019-09-19T07:00:00+00:00\",\"dateModified\":\"2025-06-25T19:42:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/\"},\"wordCount\":792,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp\",\"articleSection\":[\"Databases\",\"Internet of things\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/\",\"name\":\"Three ways to leverage composite indexes in Azure Cosmos DB | Microsoft Azure Blog\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp\",\"datePublished\":\"2019-09-19T07:00:00+00:00\",\"dateModified\":\"2025-06-25T19:42:07+00:00\",\"description\":\"Composite indexes were introduced in Azure Cosmos DB at Microsoft Build 2019. With our latest service update, additional query types can now leverage composite indexes.\",\"breadcrumb\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#primaryimage\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog home\",\"item\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Databases\",\"item\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/category\/databases\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Three ways to leverage composite indexes in Azure Cosmos DB\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\",\"name\":\"Microsoft Azure Blog\",\"description\":\"Get the latest Azure news, updates, and announcements from the Azure blog. From product updates to hot topics, hear from the Azure experts.\",\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\",\"name\":\"Microsoft Azure Blog\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp\",\"width\":512,\"height\":512,\"caption\":\"Microsoft Azure Blog\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/microsoftazure\",\"https:\/\/x.com\/azure\",\"https:\/\/www.instagram.com\/microsoftdeveloper\/\",\"https:\/\/www.linkedin.com\/company\/16188386\",\"https:\/\/www.youtube.com\/user\/windowsazure\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/person\/c702e5edd662b328b49b7e1180cab117\",\"name\":\"shakir\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g7664e653ea371ce16eaf75e9fa8952c4\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g\",\"caption\":\"shakir\"},\"sameAs\":[\"https:\/\/azure.microsoft.com\"],\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/shakir\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Three ways to leverage composite indexes in Azure Cosmos DB | Microsoft Azure Blog","description":"Composite indexes were introduced in Azure Cosmos DB at Microsoft Build 2019. With our latest service update, additional query types can now leverage composite indexes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/","og_locale":"en_US","og_type":"article","og_title":"Three ways to leverage composite indexes in Azure Cosmos DB | Microsoft Azure Blog","og_description":"Composite indexes were introduced in Azure Cosmos DB at Microsoft Build 2019. With our latest service update, additional query types can now leverage composite indexes.","og_url":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/","og_site_name":"Microsoft Azure Blog","article_publisher":"https:\/\/www.facebook.com\/microsoftazure","article_published_time":"2019-09-19T07:00:00+00:00","article_modified_time":"2025-06-25T19:42:07+00:00","og_image":[{"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp","type":"","width":"","height":""}],"author":"Microsoft Azure","twitter_card":"summary_large_image","twitter_creator":"@azure","twitter_site":"@azure","twitter_misc":{"Written by":"Microsoft Azure","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#article","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/"},"author":[{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/microsoft-azure\/","@type":"Person","@name":"Microsoft Azure"}],"headline":"Three ways to leverage composite indexes in Azure Cosmos DB","datePublished":"2019-09-19T07:00:00+00:00","dateModified":"2025-06-25T19:42:07+00:00","mainEntityOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/"},"wordCount":792,"commentCount":0,"publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp","articleSection":["Databases","Internet of things"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/","name":"Three ways to leverage composite indexes in Azure Cosmos DB | Microsoft Azure Blog","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#primaryimage"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp","datePublished":"2019-09-19T07:00:00+00:00","dateModified":"2025-06-25T19:42:07+00:00","description":"Composite indexes were introduced in Azure Cosmos DB at Microsoft Build 2019. With our latest service update, additional query types can now leverage composite indexes.","breadcrumb":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#primaryimage","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2019\/09\/410489b7-af49-4e1e-838f-f237748ef21f.webp"},{"@type":"BreadcrumbList","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/three-ways-to-leverage-composite-indexes-in-azure-cosmos-db\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog home","item":"https:\/\/azure.microsoft.com\/en-us\/blog\/"},{"@type":"ListItem","position":2,"name":"Databases","item":"https:\/\/azure.microsoft.com\/en-us\/blog\/category\/databases\/"},{"@type":"ListItem","position":3,"name":"Three ways to leverage composite indexes in Azure Cosmos DB"}]},{"@type":"WebSite","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/","name":"Microsoft Azure Blog","description":"Get the latest Azure news, updates, and announcements from the Azure blog. From product updates to hot topics, hear from the Azure experts.","publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/azure.microsoft.com\/en-us\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization","name":"Microsoft Azure Blog","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp","width":512,"height":512,"caption":"Microsoft Azure Blog"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/microsoftazure","https:\/\/x.com\/azure","https:\/\/www.instagram.com\/microsoftdeveloper\/","https:\/\/www.linkedin.com\/company\/16188386","https:\/\/www.youtube.com\/user\/windowsazure"]},{"@type":"Person","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/person\/c702e5edd662b328b49b7e1180cab117","name":"shakir","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g7664e653ea371ce16eaf75e9fa8952c4","url":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g","caption":"shakir"},"sameAs":["https:\/\/azure.microsoft.com"],"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/shakir\/"}]}},"msxcm_display_generated_audio":false,"msxcm_animated_featured_image":null,"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft Azure Blog","distributor_original_site_url":"https:\/\/azure.microsoft.com\/en-us\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/1013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/comments?post=1013"}],"version-history":[{"count":1,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/1013\/revisions"}],"predecessor-version":[{"id":43559,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/1013\/revisions\/43559"}],"wp:attachment":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/media?parent=1013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/categories?post=1013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tags?post=1013"},{"taxonomy":"audience","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/audience?post=1013"},{"taxonomy":"content-type","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/content-type?post=1013"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/product?post=1013"},{"taxonomy":"tech-community","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tech-community?post=1013"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/topic?post=1013"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/coauthors?post=1013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}