{"id":2056,"date":"2018-10-25T00:00:00","date_gmt":"2018-10-25T00:00:00","guid":{"rendered":"https:\/\/azure.microsoft.com\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1"},"modified":"2023-05-11T15:36:24","modified_gmt":"2023-05-11T22:36:24","slug":"azure-cosmos-db-partitioning-design-patterns-part-1","status":"publish","type":"post","link":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/","title":{"rendered":"Azure Cosmos DB partitioning design patterns \u2013 Part 1"},"content":{"rendered":"<p>In this article, you will learn how to use partition keys to efficiently distribute data, improve application performance, and enable faster look-up. The pre-requisites of this article are general knowledge of Azure Cosmos DB and a good understanding of <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/change-feed\">change feed<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/request-units\">request unit<\/a> (RU), and <a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/functions\/\">Azure Functions<\/a>.<\/p>\n<p>Imagine you have data which you would like to insert with high throughput and query on two or more different keys. In this scenario, suppose you work for an airline company and need to store user reservation information in a collection. User data is defined as:<\/p>\n<pre>\r\n{\r\n     UserId: user@email.com,\r\n     FirstName: John,\r\n     LastName: Doe,\r\n     PNR: 2345423,\r\n     CityOfOrigin: Seattle,\r\n     CityOfDestination: London,\r\n     DOB: 12.2.76,\r\n     other details \u2026.\r\n}<\/pre>\n<p>Out of many possible values, you choose \u201cUserId\u201d (user email address) as the partition key. This is a good choice for a partition key because \u201cUserId\u201d is unique for every user, ensuring your data remains well distributed. Your data is distributed evenly among all partitions, as shown in Figure 1. However, when you are querying the data you do not always have a \u201cUserId\u201d. Sometimes you want to query the data by user last name or user Passenger Name Record (PNR) number.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"GoodPartition\" height=\"278\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp\" title=\"GoodPartition\" width=\"321\"><\/p>\n<p align=\"center\"><em>Figure 1: Data distributed evenly across partitions<\/em><\/p>\n<p>Azure Cosmos DB indexes all data by default. If you try to query the data by &#8220;LastName&#8221;, you will get the result, but it will cost you more <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/request-units\">request units<\/a> (RU\/s) because queries without partition key become fan-out queries. Fan-out queries check all partitions, which will cost you extra RU\/s and may affect the performance of your application. If you have a small number of partitions with less data, you may not perceive any significant side effects of fan-out queries, but when you start getting in high numbers of partitions and large amounts of data, fan-out queries can be detrimental to your applications. Infrequent cross partition query is fine, but if it is a frequent query, then what is the solution?<\/p>\n<p>One option is to have two more lookup collections PNR and \u201cLastName\u201d for the mapping of PNR to \u201cUserId\u201d, and \u201cLastName\u201d to \u201cUserId\u201d. The PNR collection will have PNR as the partition key and row key and \u201cUserId\u201d as the value.\u00a0<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"clip_image002\" height=\"215\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/35380b34-d223-42b5-92c9-b0c9de91ea62.webp\" title=\"clip_image002\" width=\"659\"><\/p>\n<p>These different lookup collections will make your application more efficient. To lookup detail by PNR, first query the PNR collection to get the \u201cUserId\u201d. Then use \u201cUserId\u201d to query user collection for all details. These two calls can complete within a few milliseconds and will consume fewer RU\/s than a single fan-out query. Most of the point lookup can complete within one to two milliseconds. Even after two lookups, you can be done within 10 milliseconds for most of the queries.<\/p>\n<p>You may not want a few extra milliseconds added to calls and instead may decide to duplicate the data in the PNR and \u201cLastName\u201d collections. While this will enable fast look-up, it isn\u2019t recommended because it may add complexity and costs when data is updated. Ultimately, you must balance requirements, performance, and complexity. Starting with a simple solution is often the best approach.<\/p>\n<p>Now let\u2019s look at the distribution of your data in different collections. For example, if you look at the \u201cLastName\u201d collection you will find that the data is not equally distributed because there are more people with the last name \u201cSmith\u201d than \u201cZubrkee\u201d. In this case, the data will look very much like Figure 2.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"BadPartition\" height=\"278\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/ce4f0c82-4f2b-4e0c-8e2f-fd1ec96f8945.webp\" title=\"BadPartition\" width=\"320\"><\/p>\n<p align=\"center\"><em>Figure 2: Data unevenly distributed across partitions<\/em><\/p>\n<p>The data in this scenario is distributed unevenly, with some full partitions and others greatly underused. This type of data distribution creates many problems.<\/p>\n<ul>\n<li>The total RU\/s for a collection is divided amongst all partitions. This means that 1000 RU\/s will be distributed across five partitions as 200 RU\/s for each partition. If you try to write more than 200 RU\/s to any of these partitions, calls will begin to fail as you cross the threshold. If a developer finds they\u2019re getting throttled on 300 RU\/s despite having 1000 RU\/s allocated at the collection level, the issue is often that a bad partition key is hitting only one partition.<\/li>\n<li>A partition key can currently have 10 GB of data at maximum (this may change in future), making it important to use a partition key which fills all partitions efficiently. In the example of \u201cLastName\u201d, a more granular partition key is needed to evenly distribute data. Since the data also includes \u201cOrigin City\u201d, a new partition key can be made from \u201cLastName\u201d and \u201cOrigin City\u201d and the results will look like Figure 3 below.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"NotBadPartition\" height=\"285\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/cde41df7-c3b8-45bd-97f8-661be847d04b.webp\" title=\"NotBadPartition\" width=\"323\"><\/p>\n<p align=\"center\"><em>Figure 3: Data distribution after applying granular partition key<\/em><\/p>\n<p>This looks much better. The data is distributed more evenly, and travelers can easily and quickly look-up their reservations by simply entering their last name and city of origin.<\/p>\n<p>Now that you\u2019ve distributed your data evenly, how do you populate the other collection? For this, we need to understand change feed. <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/change-feed\">Change feed<\/a> exposes all the internal changes happening inside a collection. Change feed support in Azure Cosmos DB works by listening to an Azure Cosmos DB collection for any changes. It then outputs the sorted list of documents that were changed in the order in which they were modified. The changes are persisted, can be processed asynchronously and incrementally, and the output can be distributed across one or more consumers for parallel processing.<\/p>\n<p>The change feed is available for each partition key range within the document collection and thus can be distributed across one or more consumers for parallel processing. Whenever a record is inserted into the user collection it will appear in change feed. The easiest way to consume change feed is Azure Function. Azure Functions is a <a href=\"https:\/\/azure.microsoft.com\/solutions\/serverless\/\">serverless<\/a> compute service that enables you to run code-on-demand without having to explicitly provision or manage infrastructure. Use Azure Functions to run a script or piece of code in response to a variety of events.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"PNRAF\" height=\"385\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/2604e7e9-8ed9-4946-8a33-c97d0d710045.webp\" title=\"PNRAF\" width=\"564\"><\/p>\n<p>When you consume change feed through Azure function, all the inserted\/changed documents come in your function as a parameter of your function.<\/p>\n<pre>\r\npublic static async Task Run(IReadOnlyList<Document> input, TraceWriter log)<\/pre>\n<p>Once you have the whole document in your function, you can update the PNR and \u201cLastName\u201d collection accordingly.\u00a0<\/p>\n<p>Watch this <a href=\"https:\/\/www.youtube.com\/watch?v=iprndNsUeeg&#038;t=454s\">screencast<\/a> to learn more about how to use Azure Cosmos DB, Azure Function and change feed or read about change feed:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/change-feed#azure-functions\">Using Azure Functions<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/change-feed#sql-sdk\">Using the Azure Cosmos DB SDK<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/change-feed#change-feed-processor\">Using the Azure Cosmos DB change feed processor library<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In this article, you will learn how to use partition keys to efficiently distribute data, improve application performance, and enable faster look-up. The pre-requisites of this article are general knowledge of Azure Cosmos DB and a good understanding of change feed, request unit (RU) and Azure Functions.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","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,3053,3056],"content-type":[1481],"product":[1538],"tech-community":[],"topic":[],"coauthors":[97],"class_list":["post-2056","post","type-post","status-publish","format-standard","hentry","category-databases","category-internet-of-things","audience-data-professionals","audience-developers","audience-it-decision-makers","audience-it-implementors","content-type-thought-leadership","product-azure-cosmos-db"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Azure Cosmos DB partitioning design patterns \u2013 Part 1 | Microsoft Azure Blog<\/title>\n<meta name=\"description\" content=\"In this article, you will learn how to use partition keys to efficiently distribute data, improve application performance, and enable faster look-up. The pre-requisites of this article are general knowledge of Azure Cosmos DB and a good understanding of change feed, request unit (RU) and Azure Functions.\" \/>\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\/azure-cosmos-db-partitioning-design-patterns-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Azure Cosmos DB partitioning design patterns \u2013 Part 1 | Microsoft Azure Blog\" \/>\n<meta property=\"og:description\" content=\"In this article, you will learn how to use partition keys to efficiently distribute data, improve application performance, and enable faster look-up. The pre-requisites of this article are general knowledge of Azure Cosmos DB and a good understanding of change feed, request unit (RU) and Azure Functions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/\" \/>\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=\"2018-10-25T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-11T22:36:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.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=\"5 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\/azure-cosmos-db-partitioning-design-patterns-part-1\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/\"},\"author\":[{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/microsoft-azure\/\",\"@type\":\"Person\",\"@name\":\"Microsoft Azure\"}],\"headline\":\"Azure Cosmos DB partitioning design patterns \u2013 Part 1\",\"datePublished\":\"2018-10-25T00:00:00+00:00\",\"dateModified\":\"2023-05-11T22:36:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/\"},\"wordCount\":1046,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp\",\"articleSection\":[\"Databases\",\"Internet of things\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/\",\"name\":\"Azure Cosmos DB partitioning design patterns \u2013 Part 1 | Microsoft Azure Blog\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp\",\"datePublished\":\"2018-10-25T00:00:00+00:00\",\"dateModified\":\"2023-05-11T22:36:24+00:00\",\"description\":\"In this article, you will learn how to use partition keys to efficiently distribute data, improve application performance, and enable faster look-up. The pre-requisites of this article are general knowledge of Azure Cosmos DB and a good understanding of change feed, request unit (RU) and Azure Functions.\",\"breadcrumb\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#primaryimage\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#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\":\"Azure Cosmos DB partitioning design patterns \u2013 Part 1\"}]},{\"@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":"Azure Cosmos DB partitioning design patterns \u2013 Part 1 | Microsoft Azure Blog","description":"In this article, you will learn how to use partition keys to efficiently distribute data, improve application performance, and enable faster look-up. The pre-requisites of this article are general knowledge of Azure Cosmos DB and a good understanding of change feed, request unit (RU) and Azure Functions.","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\/azure-cosmos-db-partitioning-design-patterns-part-1\/","og_locale":"en_US","og_type":"article","og_title":"Azure Cosmos DB partitioning design patterns \u2013 Part 1 | Microsoft Azure Blog","og_description":"In this article, you will learn how to use partition keys to efficiently distribute data, improve application performance, and enable faster look-up. The pre-requisites of this article are general knowledge of Azure Cosmos DB and a good understanding of change feed, request unit (RU) and Azure Functions.","og_url":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/","og_site_name":"Microsoft Azure Blog","article_publisher":"https:\/\/www.facebook.com\/microsoftazure","article_published_time":"2018-10-25T00:00:00+00:00","article_modified_time":"2023-05-11T22:36:24+00:00","og_image":[{"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#article","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/"},"author":[{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/microsoft-azure\/","@type":"Person","@name":"Microsoft Azure"}],"headline":"Azure Cosmos DB partitioning design patterns \u2013 Part 1","datePublished":"2018-10-25T00:00:00+00:00","dateModified":"2023-05-11T22:36:24+00:00","mainEntityOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/"},"wordCount":1046,"commentCount":0,"publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp","articleSection":["Databases","Internet of things"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/","name":"Azure Cosmos DB partitioning design patterns \u2013 Part 1 | Microsoft Azure Blog","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#primaryimage"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp","datePublished":"2018-10-25T00:00:00+00:00","dateModified":"2023-05-11T22:36:24+00:00","description":"In this article, you will learn how to use partition keys to efficiently distribute data, improve application performance, and enable faster look-up. The pre-requisites of this article are general knowledge of Azure Cosmos DB and a good understanding of change feed, request unit (RU) and Azure Functions.","breadcrumb":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#primaryimage","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2018\/10\/3a5b75b8-9abd-4224-bc1e-c4f67a50b24a.webp"},{"@type":"BreadcrumbList","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/azure-cosmos-db-partitioning-design-patterns-part-1\/#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":"Azure Cosmos DB partitioning design patterns \u2013 Part 1"}]},{"@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\/2056","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=2056"}],"version-history":[{"count":0,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/2056\/revisions"}],"wp:attachment":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/media?parent=2056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/categories?post=2056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tags?post=2056"},{"taxonomy":"audience","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/audience?post=2056"},{"taxonomy":"content-type","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/content-type?post=2056"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/product?post=2056"},{"taxonomy":"tech-community","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tech-community?post=2056"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/topic?post=2056"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/coauthors?post=2056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}