{"id":7358,"date":"2024-01-08T07:00:17","date_gmt":"2024-01-08T15:00:17","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=7358"},"modified":"2024-02-08T21:16:36","modified_gmt":"2024-02-09T05:16:36","slug":"best-practices-for-re-modeling-graph-database-to-azure-cosmos-db-for-nosql","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/best-practices-for-re-modeling-graph-database-to-azure-cosmos-db-for-nosql\/","title":{"rendered":"Best Practices for Re-modeling Graph database to Azure Cosmos DB for NoSQL"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p>Azure Cosmos DB is Microsoft&#8217;s premier fully managed NoSQL database for modern app development. It is ideal for solutions including artificial intelligence, digital commerce, Internet of Things, booking management and other types of use cases. It offers single-digit millisecond response times, automatic and instant scalability along with guaranteed speed at any scale. Azure Cosmos DB&#8217;s NoSQL offering stands out with its exceptional performance and robust feature set that can be an alternative to using graph databases.<\/p>\n<p>This blog post outlines the approach and best practices, we, the authors learned while working with a customer who wanted to transition a graph workload to Azure Cosmos DB for NoSQL. Our insights are based on our collaboration with various teams, including software engineering and Line-Of-Business (LOB) application teams, at Walmart.<\/p>\n<h2><strong>When should I do this?<\/strong><\/h2>\n<p>Azure Cosmos DB for NoSQL is recommended for building green-field applications. However, if users are committed to refactoring their code, it can also be used in scenarios where users are attempting to squeeze the most performance for their applications. The scenario highlighted here is an application currently using a graph as the back-end database for storing, querying and analyzing data relationships. In this blog post we will illustrate using the Gremlin graph database and provide guidance to re-model the same into Azure Cosmos DB for NoSQL.<\/p>\n<p>The three important qualifying factors wherein this approach is valid include:<\/p>\n<ol>\n<li>Your use-case leverages point-reads most of the time (&gt; 80%) for querying data.<\/li>\n<li>Your use-case leverages 1-x traversals most of the time (&gt; 80%) for querying data.<\/li>\n<li>Your use-case leverages a combination of point-reads and 1-x traversals most of the time (&gt;80%) for querying data.<\/li>\n<\/ol>\n<p>This approach is <strong>not<\/strong> recommended if you are mostly doing a 2x- and 3x- or more level of traversals with complex edge-relationships and\/or data size of database is &gt; 5 TBs.<\/p>\n<p><div class=\"alert alert-primary\"><span style=\"font-size: 10pt;\">NOTE: This post is not a recommendation for all customers using Gremlin API or any graph database, to migrate to Azure Cosmos DB for NoSQL. This blog post is intended to highlight how one customer approached this given their needs and the specific factors mentioned above.<\/span><\/div><\/p>\n<h2><strong>Approach<\/strong><\/h2>\n<p><span data-contrast=\"auto\">Ideally, the recommended approach is to simulate the Gremlin API data model and vertex (aka node) to vertex traversals via edges using Azure Cosmos DB for NoSQL. The table below documents the source and destination:\u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<table class=\" aligncenter\" style=\"border-collapse: collapse; width: 62.6364%; height: 256px;\">\n<tbody>\n<tr style=\"height: 28px;\">\n<td style=\"width: 55.9943%; text-align: center; height: 28px;\"><strong>Currently in Azure Cosmos DB\u00a0<\/strong><strong>for Gremlin<\/strong><\/td>\n<td style=\"width: 84.812%; text-align: center; height: 28px;\"><strong>Proposed in Azure Cosmos DB\u00a0<\/strong><strong>for NoSQL<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 55.9943%; text-align: center; height: 28px;\">Vertex (Node)<\/td>\n<td style=\"width: 84.812%; text-align: center; height: 28px;\">Item<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 55.9943%; text-align: center; height: 28px;\">Edge (Relationship)<\/td>\n<td style=\"width: 84.812%; text-align: center; height: 28px;\">Item<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 55.9943%; text-align: center; height: 28px;\">A forward edge (i.e., a forward traversal). E.g., A &#8211;&gt; B<\/td>\n<td style=\"width: 84.812%; text-align: center; height: 28px;\">Item<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 55.9943%; text-align: center; height: 28px;\">A reverse edge (i.e., a backward traversal). E.g., B &#8211;&gt; A<\/td>\n<td style=\"width: 84.812%; text-align: center; height: 28px;\">Item<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\n<\/span><span data-contrast=\"auto\">\nIn essence the approach is to create 4 items.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h2><strong>Re-modeling \u2013 an example<\/strong><\/h2>\n<p><span data-contrast=\"auto\">A graph is just a collection of vertices and edges \u2013 or, in other words, a set of nodes and the relationships that connect them. Graphs represent entities as nodes and the ways in which those entities relate to the world as relationships. This general-purpose, expressive structure allows us to model all kinds of scenarios. In the example below, for a retail online sales scenario, we are building a graphical representation of a customer data point. Our vertex has id: Cust001, label: customer and properties including email address, address, first seen, last seen, device1, device2 and so on. Device identified by id Device_1 is in turn shared by customer identified by id: Cust006, and device identified by id Device_2 is shared by two other customers, identified by id: Cust81 and Cust431.<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/graph.png\"><img decoding=\"async\" class=\"wp-image-7362 size-large aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/graph-1024x637.png\" alt=\"Graph model representation of an Ecommerce data mode.\" width=\"640\" height=\"398\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/graph-1024x637.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/graph-300x187.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/graph-768x477.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/graph.png 1401w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><span data-contrast=\"auto\">This Gremlin API data model vertex could be represented in <\/span><span data-contrast=\"auto\">an <\/span><span data-contrast=\"auto\">Azure Cosmos DB for NoSQL data model in the following JSON representation:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre>{\r\n\r\n     \"doc_type\": \"node\",\r\n     \"id\": \"&lt;&lt;generate guid&gt;&gt;\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<span style=\"color: #000000;\">\/\/ generate a GUID<\/span>\r\n     \"type\": \"[Type]\",\r\n     \"key\": \"[Key]\",\r\n     \"pk\": \"[Type + Key]\",                      <span style=\"color: #000000;\">\/\/ generate a partition key<\/span>\r\n     \"first_seen\": \"[first_seen]\",\r\n     \"last_seen\": \"[last_seen]\",\r\n     \"details\": {\r\n              \"a1\": \"v1\",\r\n              \"a2\": \"v2\",\r\n              \".com\": {\r\n                    \"x\": {\r\n                       \"p\": \"abc\",\r\n                       \"g\": \"def\"\r\n                    },\r\n                    \"com_fs\": \"\",\r\n                    \"com_ls\": \"\",\r\n                    \"mp_fs\": \"\",\r\n                    \"mp_ls\": \"\",\r\n                    \"last_\"\r\n     },\r\n}<\/pre>\n<p><span class=\"TextRun SCXW209970222 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW209970222 BCX8\">The <\/span><span class=\"NormalTextRun SCXW209970222 BCX8\">edge (forward direction) traversal item could be represented as:<\/span><\/span><span class=\"EOP SCXW209970222 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre>{\u00a0\r\n     \"doc_type\": \"edge\",\r\n     \"id\": \"&lt;&lt;generate guid&gt;&gt;\",                 <span style=\"color: #000000;\">\/\/ [Edge.Node1.key].[Edge.Node2.key].[Edge.Type]<\/span>\r\n     \"type\": \"[Type],                           <span style=\"color: #000000;\">\/\/ alternatively, \"[Edge.Node1.key]\" <\/span>\r\n     \"key\": \"[Key]\",\r\n     \"pk\": \"[Type + Key]\", \r\n     \"first_seen\": \"[first_seen]\",\r\n     \"last_seen\": \"[last_seen]\",\r\n     \"details\": {\r\n              \"a1\": \"v1\",\r\n              \"a2\": \"v2\",\r\n              \".com\": { \r\n                    \"x\": {\r\n                       \"p\": \"abc\",\r\n                       \"g\": \"def\" \r\n                    },\r\n                    \"com_fs\": \"\",\r\n                    \"com_ls\": \"\",\r\n                    \"mp_fs\": \"\",\r\n                    \"mp_ls\": \"\"\r\n                    \"last_\"\r\n     },\r\n}\u00a0\r\n\r\n<\/pre>\n<h2><strong>A practical example<\/strong><\/h2>\n<h3><strong>Gremlin API data mode and queries<\/strong><\/h3>\n<div>We use the <a href=\"https:\/\/github.com\/krlawrence\/graph\/blob\/master\/sample-data\/air-routes.graphml\">air-routes<\/a> graph model that allows one to plan their air routes in terms of finding the shortest path or multiple routes to reach from a source to a destination. We have also migrated the air-routes data to Azure Cosmos DB for Gremlin which is available <a href=\"https:\/\/github.com\/faizc\/cosmos\/tree\/main\/azure-cosmos-gremlin-docs\">here<\/a> for you to experiment with.<\/div>\n<div><\/div>\n<div><\/div>\n<div><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes.jpg\"><img decoding=\"async\" class=\"size-large wp-image-7405 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes-1024x600.jpg\" alt=\"Image air routes\" width=\"640\" height=\"375\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes-1024x600.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes-300x176.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes-768x450.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes-1536x900.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes.jpg 1894w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/div>\n<div>\n<p style=\"text-align: center;\"><span data-contrast=\"auto\">Click <a href=\"https:\/\/github.com\/anthonychu\/cosmosdb-gremlin-flights\/blob\/master\/cosmosdb-flights.gif\">here<\/a> for Image Reference<\/span><\/p>\n<p><span data-contrast=\"auto\">The GitHub sample contains 4 vertex types. The vertices airport, country<\/span><span data-contrast=\"auto\">,<\/span><span data-contrast=\"auto\"> and continent are important. The version vertex exists for the purpose of tracking the version of the graph. The following shows the number of vertices for each type.<\/span><\/p>\n<\/div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes1.png\"><img decoding=\"async\" class=\"alignnone wp-image-7409 \" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes1.png\" alt=\"Image air routes1\" width=\"539\" height=\"31\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes1.png 556w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes1-300x17.png 300w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/a><\/p>\n<p><span class=\"TextRun SCXW76985875 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW76985875 BCX8\">Airport vertex has<\/span> <span class=\"NormalTextRun SCXW76985875 BCX8\">a few<\/span><span class=\"NormalTextRun SCXW76985875 BCX8\"> properties associated with it <\/span><span class=\"NormalTextRun SCXW76985875 BCX8\">which<\/span> <span class=\"NormalTextRun SCXW76985875 BCX8\">provide<\/span><span class=\"NormalTextRun SCXW76985875 BCX8\"> airport related information like number of runways, elevation<\/span><span class=\"NormalTextRun SCXW76985875 BCX8\">, geographical location<\/span><\/span><span class=\"TrackChangeTextInsertion TrackedChange SCXW76985875 BCX8\"><span class=\"TextRun SCXW76985875 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW76985875 BCX8\">,<\/span><\/span><\/span><span class=\"TextRun SCXW76985875 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW76985875 BCX8\"> etc.<\/span><\/span><span class=\"EOP SCXW76985875 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes2.png\"><img decoding=\"async\" class=\"alignnone wp-image-7410 \" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes2.png\" alt=\"Image air routes2\" width=\"579\" height=\"344\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes2.png 660w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes2-300x178.png 300w\" sizes=\"(max-width: 579px) 100vw, 579px\" \/><\/a><\/p>\n<p><span class=\"TextRun SCXW229603100 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW229603100 BCX8\">Routes are edges that connect the countries and the airports<\/span><span class=\"NormalTextRun SCXW229603100 BCX8\">. They<\/span><span class=\"NormalTextRun SCXW229603100 BCX8\"> have<\/span><span class=\"NormalTextRun SCXW229603100 BCX8\"> a<\/span><span class=\"NormalTextRun SCXW229603100 BCX8\"> distance property to calculate the distance between the two connected airport vertices. <\/span><span class=\"NormalTextRun SCXW229603100 BCX8\">The f<\/span><span class=\"NormalTextRun SCXW229603100 BCX8\">ollowing shows the number of edges for each <\/span><span class=\"NormalTextRun SCXW229603100 BCX8\">type.<\/span><\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes3.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-7412\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes3.png\" alt=\"Image air routes3\" width=\"314\" height=\"28\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes3.png 314w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes3-300x28.png 300w\" sizes=\"(max-width: 314px) 100vw, 314px\" \/><\/a><\/p>\n<p><span class=\"NormalTextRun SCXW152091875 BCX8\">The f<\/span><span class=\"NormalTextRun SCXW152091875 BCX8\">ollowing shows a s<\/span><span class=\"NormalTextRun SCXW152091875 BCX8\">ample edge connection <\/span><span class=\"NormalTextRun SCXW152091875 BCX8\">between <\/span><span class=\"NormalTextRun SCXW152091875 BCX8\">two airport<\/span><span class=\"NormalTextRun SCXW152091875 BCX8\">s<\/span> <span class=\"NormalTextRun SCXW152091875 BCX8\">with<\/span><span class=\"NormalTextRun SCXW152091875 BCX8\"> properties label and distance between the airports.<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes4.png\"><img decoding=\"async\" class=\"alignnone wp-image-7413 \" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes4-300x61.png\" alt=\"Image air routes4\" width=\"344\" height=\"70\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes4-300x61.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes4.png 539w\" sizes=\"(max-width: 344px) 100vw, 344px\" \/><\/a><\/p>\n<p><span class=\"TextRun SCXW122862920 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentStart SCXW122862920 BCX8\">The <\/span><span class=\"NormalTextRun SCXW122862920 BCX8\">image below <\/span><span class=\"NormalTextRun SCXW122862920 BCX8\">represents<\/span><span class=\"NormalTextRun SCXW122862920 BCX8\"> the sample <\/span><span class=\"NormalTextRun SCXW122862920 BCX8\">mode<\/span><span class=\"NormalTextRun SCXW122862920 BCX8\">l<\/span><span class=\"NormalTextRun SCXW122862920 BCX8\"> with all the vertices and edges<\/span><span class=\"NormalTextRun SCXW122862920 BCX8\">.<\/span><\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes5.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-7414\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes5.png\" alt=\"Image air routes5\" width=\"520\" height=\"354\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes5.png 520w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes5-300x204.png 300w\" sizes=\"(max-width: 520px) 100vw, 520px\" \/><\/a><\/p>\n<p><span class=\"TextRun SCXW157318174 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW157318174 BCX8\">Let<\/span><span class=\"NormalTextRun SCXW157318174 BCX8\"> us<\/span><span class=\"NormalTextRun SCXW157318174 BCX8\"> execute <\/span><span class=\"NormalTextRun SCXW157318174 BCX8\">a <\/span><span class=\"NormalTextRun SCXW157318174 BCX8\">few queries on the model and then simulate the same in <\/span><span class=\"NormalTextRun SCXW157318174 BCX8\">NoSQL.<\/span><\/span><\/p>\n<h3><b><span data-contrast=\"auto\">Single Traversal<\/span><\/b><\/h3>\n<pre><span style=\"color: #008000;\">\/\/ List all the airports for the country India\u00a0<\/span>\r\n<span data-contrast=\"auto\">g.V().has(\"country\",\"desc\",\"India\").out(\"contains\").values(\"city\")<\/span><\/pre>\n<p><span data-contrast=\"auto\">The output is as exhibited below:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes6.png\"><img decoding=\"async\" class=\"alignnone wp-image-7417 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes6.png\" alt=\"Image air routes6\" width=\"906\" height=\"132\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes6.png 906w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes6-300x44.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes6-768x112.png 768w\" sizes=\"(max-width: 906px) 100vw, 906px\" \/><\/a>\n<span class=\"TextRun SCXW124852773 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW124852773 BCX8\">Approximate <\/span><span class=\"NormalTextRun SCXW124852773 BCX8\">Request Unit (<\/span><span class=\"NormalTextRun SCXW124852773 BCX8\">RU<\/span><span class=\"NormalTextRun SCXW124852773 BCX8\">)<\/span><span class=\"NormalTextRun SCXW124852773 BCX8\"> consumption = <strong>25 RU\/s<\/strong>\u00a0<\/span><\/span><span class=\"EOP SCXW124852773 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h3><b><span data-contrast=\"auto\">Double Traversal\u00a0<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559731&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<pre><span data-contrast=\"none\"><span style=\"color: #008000;\">\/\/ Bangalore to San Francisco with 1 hop\/layover<\/span>\r\n<\/span><span data-contrast=\"auto\">g.V().has(\"code\",\"BOM\").out().out().has(\"code\",\"SFO\").path().by(\"code\")<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:345,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/pre>\n<p><span class=\"NormalTextRun SCXW222990825 BCX8\">The output is as <\/span><span class=\"NormalTextRun SCXW222990825 BCX8\">exhibited<\/span><span class=\"NormalTextRun SCXW222990825 BCX8\"> below:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes7.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-7419\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes7.png\" alt=\"Image air routes7\" width=\"910\" height=\"68\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes7.png 910w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes7-300x22.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes7-768x57.png 768w\" sizes=\"(max-width: 910px) 100vw, 910px\" \/><\/a>\n<span class=\"TextRun SCXW210668907 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW210668907 BCX8\">Approximate <\/span><span class=\"NormalTextRun SCXW210668907 BCX8\">RU<\/span><span class=\"NormalTextRun SCXW210668907 BCX8\"> consumption = <strong>770 RU\/s<\/strong><\/span><\/span><\/p>\n<pre><span data-contrast=\"none\"><span style=\"color: #008000;\">\/\/ Find the top ten overall in terms of incoming routes<\/span>\r\n<\/span><span data-contrast=\"auto\">g.V().hasLabel('airport').order().by(__.in('route').count(),decr).limit(10).project('ap','routes').by('code').by(__.in('route').count())<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:345,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes8.png\"><img decoding=\"async\" class=\"alignnone wp-image-7422\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes8-1024x40.png\" alt=\"Image air routes8\" width=\"896\" height=\"35\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes8-1024x40.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes8-300x12.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes8-768x30.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes8-1536x59.png 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes8.png 1550w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a>\n<span class=\"TextRun SCXW48779228 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW48779228 BCX8\">Approximate <\/span><span class=\"NormalTextRun SCXW48779228 BCX8\">RU<\/span><span class=\"NormalTextRun SCXW48779228 BCX8\"> consumption = <\/span><strong><span class=\"NormalTextRun SCXW48779228 BCX8\">11,900<\/span><span class=\"NormalTextRun SCXW48779228 BCX8\"> RU\/s<\/span><\/strong><\/span><\/p>\n<h2><b><span data-contrast=\"auto\">Azure Cosmos DB for NoSQL model and queries<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">Understanding query access patterns is critical before designing a data model for your use-case in Azure Cosmos DB for NoSQL. Based on your application specific query patterns, it is advisable to create a schema and choose the partition key for your container. This results in a highly optimized and cost-efficient data model in Azure Cosmos DB for NoSQL.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">In this case, the schema of the model will include forward and reverse traversal for the vertices and edges. Additionally, the query access pattern will help us in defining the partition key and additional attributes.\u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">A basic Gremlin API data model when translated into a NoSQL data model looks similar to:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes9.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-7425\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes9.png\" alt=\"Image air routes9\" width=\"628\" height=\"308\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes9.png 628w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/air-routes9-300x147.png 300w\" sizes=\"(max-width: 628px) 100vw, 628px\" \/><\/a><\/p>\n<p><span data-contrast=\"auto\">How do we map vertex and edge to NoSQL documents effectively? <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559731&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"45\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"auto\">The partition key is determined based on the query to be performed and different vertices and edge combinations.\u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"45\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"3\" data-aria-level=\"1\"><span data-contrast=\"auto\">For an <strong>edge<\/strong>, a generic example for a combination of <\/span><span data-contrast=\"auto\">\u201cvertex-type\u201d+\u201dvertex-key\u201d+\u201dedge-type\u201d<\/span><span data-contrast=\"auto\"> would help perform traversal from one vertex to another using the edge relationship. You can actually traverse to any depth with this combination.<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"45\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"4\" data-aria-level=\"1\"><span data-contrast=\"auto\">For a <strong>vertex<\/strong>, a generic example for a combination of <\/span><span data-contrast=\"auto\">\u201cvertex-type\u201d+\u201dvertex-key\u201d<\/span><span data-contrast=\"auto\"> is good enough to grab the relevant information.<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"auto\">Note: The partition key combination will vary depending on your use case.<\/span><\/p>\n<p style=\"text-align: left;\"><span data-contrast=\"auto\">Let us take the air-routes graph data and model it into the Azure Cosmos DB for NoSQL model that would help us execute similar queries.<\/span><\/p>\n<p style=\"text-align: center;\"><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\n<\/span><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/Gremlin-to-NoSQL-QueryPatterns.png\"><img decoding=\"async\" class=\"size-large wp-image-7427 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/Gremlin-to-NoSQL-QueryPatterns-1024x542.png\" alt=\"Image Gremlin to NoSQL QueryPatterns\" width=\"640\" height=\"339\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/Gremlin-to-NoSQL-QueryPatterns-1024x542.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/Gremlin-to-NoSQL-QueryPatterns-300x159.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/Gremlin-to-NoSQL-QueryPatterns-768x406.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/Gremlin-to-NoSQL-QueryPatterns-1536x813.png 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/12\/Gremlin-to-NoSQL-QueryPatterns.png 1850w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><span class=\"TextRun SCXW172290371 BCX8\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW172290371 BCX8\">(Click to enlarge image)<\/span><\/span><\/p>\n<h3><b><span data-contrast=\"auto\">Single Traversal<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559731&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<pre><span data-contrast=\"none\">\/\/ List all the airports for the country India<\/span>\u00a0\r\n<span data-contrast=\"none\">select<\/span><span data-contrast=\"none\">\u202fc.destination,\u202fc.destinationType\u202f<\/span><span data-contrast=\"none\">from<\/span><span data-contrast=\"none\">\u202fc\u202f<\/span><span data-contrast=\"none\">where<\/span><span data-contrast=\"none\">\u202fc.partitionKey<\/span><span data-contrast=\"none\">=<\/span><span data-contrast=\"none\">'country_India_contains'<\/span><span data-contrast=\"none\">\u202f<\/span><span data-contrast=\"none\">and<\/span><span data-contrast=\"none\">\u202fc.doc_type<\/span><span data-contrast=\"none\">=<\/span><span data-contrast=\"none\">'edge'<\/span><span data-ccp-props=\"{&quot;201341983&quot;:2,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/pre>\n<p><span data-contrast=\"auto\">Approximate RU: <strong>3-5 RU\/s\u00a0<\/strong><\/span><strong>\u00a0<\/strong><\/p>\n<p><span data-contrast=\"auto\">This query would return all the vertices i.e. the forward linkages from country to airport. Once the vertices are available then the node related details can easily be extracted using the point-read operation.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h3><b><span data-contrast=\"auto\">Double Traversal<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<pre><span data-contrast=\"none\">\/\/ List all the flights between Mumbai to San Francisco with one layover\u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/pre>\n<p><span data-contrast=\"auto\">Since it is double traversal (i.e. like performing multiple out in Gremlin), we would be executing 2\u00a0<\/span><span data-contrast=\"auto\">queries,\u00a0first query to get all the routes from Mumbai and second query to get all the routes flowing into San<\/span><span data-contrast=\"auto\"> Francisco<\/span><span data-contrast=\"auto\"> (like an in operation).<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h4><span data-contrast=\"none\">First Query<\/span><\/h4>\n<pre><span data-contrast=\"none\">select<\/span><span data-contrast=\"none\">\u202fc.destination,\u202fc.destinationType\u202f<\/span><span data-contrast=\"none\">from<\/span><span data-contrast=\"none\">\u202fc\u202f<\/span><span data-contrast=\"none\">where<\/span><span data-contrast=\"none\">\u202fc.partitionKey<\/span><span data-contrast=\"none\">=<\/span><span data-contrast=\"none\">'airport_Mumbai_route'<\/span><span data-contrast=\"none\">\u202f<\/span><span data-contrast=\"none\">and<\/span><span data-contrast=\"none\">\u202fc.doc_type<\/span><span data-contrast=\"none\">=<\/span><span data-contrast=\"none\">'edge'<\/span><span data-ccp-props=\"{&quot;201341983&quot;:2,&quot;335559685&quot;:360,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/pre>\n<h4><span data-contrast=\"none\">Second Query<\/span><\/h4>\n<pre><span data-contrast=\"none\">select<\/span><span data-contrast=\"none\">\u202fc.destination,\u202fc.destinationType\u202f<\/span><span data-contrast=\"none\">from<\/span><span data-contrast=\"none\">\u202fc\u202f<\/span><span data-contrast=\"none\">where<\/span><span data-contrast=\"none\">\u202fc.partitionKey<\/span><span data-contrast=\"none\">=<\/span><span data-contrast=\"none\">'airport_San<\/span> <span data-contrast=\"none\">Francisco_route'<\/span><span data-contrast=\"none\">\u202f<\/span><span data-contrast=\"none\">and<\/span><span data-contrast=\"none\">\u202fc.doc_type<\/span><span data-contrast=\"none\">=<\/span><span data-contrast=\"none\">'edge'<\/span><span data-ccp-props=\"{&quot;201341983&quot;:2,&quot;335559685&quot;:360,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/pre>\n<p><span data-contrast=\"auto\">The union of destinations from both the queries would result in<\/span><span data-contrast=\"auto\">to<\/span><span data-contrast=\"auto\"> all the routes between Mumbai\u00a0<\/span><span data-contrast=\"auto\">to and\u00a0San Francisco. <\/span><\/p>\n<p><span data-contrast=\"auto\">Approximate RU: <strong>11-15 RU\/s<\/strong> for both the queries<\/span><span data-contrast=\"auto\">.<\/span><span data-contrast=\"auto\">\u00a0\u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:2,&quot;335559685&quot;:360,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<pre><span data-contrast=\"none\">\/\/ Find the top ten overall in terms of incoming routes<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559731&quot;:345,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span>\r\n<span data-contrast=\"none\">select<\/span><span data-contrast=\"none\">\u202f<\/span><span data-contrast=\"none\">COUNT<\/span><span data-contrast=\"none\">(<\/span><span data-contrast=\"none\">1<\/span><span data-contrast=\"none\">)\u202f<\/span><span data-contrast=\"none\">as<\/span><span data-contrast=\"none\">\u202finroutes,c.destination\u202f<\/span><span data-contrast=\"none\">from<\/span><span data-contrast=\"none\">\u202fc\u202f<\/span><span data-contrast=\"none\">where<\/span><span data-contrast=\"none\">\u202fENDSWITH(c.partitionKey,\u202f<\/span><span data-contrast=\"none\">'_route'<\/span><span data-contrast=\"none\">)\u202f<\/span><span data-contrast=\"none\">and<\/span><span data-contrast=\"none\">\u202fc.doc_type<\/span><span data-contrast=\"none\">=<\/span><span data-contrast=\"none\">'edge'<\/span><span data-contrast=\"none\">\u202f<\/span><span data-contrast=\"none\">GROUP<\/span><span data-contrast=\"none\">\u202f<\/span><span data-contrast=\"none\">BY<\/span><span data-contrast=\"none\">\u202fc.destination\u202f<\/span><span data-ccp-props=\"{&quot;201341983&quot;:2,&quot;335559685&quot;:345,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/pre>\n<p><span data-contrast=\"auto\">The query would list the destination with the number of incoming routes to the destination airport. The results would not be ordered but <\/span><span data-contrast=\"auto\">this <\/span><span data-contrast=\"auto\">can be done easily within the code.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:2,&quot;335559685&quot;:360,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Approximate RU: <strong>2,935 RU\/s<\/strong><\/span><span data-contrast=\"auto\">.<\/span><\/p>\n<h2><b><span data-contrast=\"auto\">Seven best practices to follow<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">The following best practices are recommended:<\/span><\/p>\n<ol>\n<li><span data-contrast=\"auto\">Store the vertex properties as a separate item rather than storing it inline. This reduces storage cost<\/span><span data-contrast=\"auto\">s<\/span><span data-contrast=\"auto\"> and ensures data consistency irrespective of read from either forward or reverse direction.<\/span><\/li>\n<li><span data-contrast=\"auto\">For high-volume low-latency scenarios, create all 3 items (edge-details, and 2 traversal items) as part of a single transaction.<\/span><\/li>\n<li><span data-contrast=\"auto\">Query on these items using the source partition key (pk) and src which represents source.<\/span><\/li>\n<li><span data-contrast=\"auto\">Use the <\/span><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/partial-document-update\"><span data-contrast=\"none\">Patch API<\/span><\/a><span data-contrast=\"auto\"> for updating specific properties within an item. The following operations are supported: Add, Set, Replace, Remove, Increment and Move.<\/span><\/li>\n<li><span data-contrast=\"auto\">If you have a high-volume low-latency scenario wherein you need to update specific properties within an item, use Patch API for updating all 3 documents (e.g., in our use case scenario, the edge-details and 2 traversal items) as part of a single transaction.<\/span><\/li>\n<li><span data-contrast=\"auto\">RU\/s utilization is better in Azure Cosmos DB for NoSQL than the Gremlin API.<\/span><\/li>\n<li><span data-contrast=\"auto\">Finally, you can leverage Change Feed to create\/update the reverse traversal item. This keeps client code simple. Please note the downside for this approach: new items\/updates to items will not be available instantly.<\/span><\/li>\n<\/ol>\n<h2><b><span data-contrast=\"auto\">Limitations<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<ol>\n<li data-leveltext=\"%1.\" data-font=\"Calibri Light,Times New Roman\" data-listid=\"46\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"1\" data-aria-level=\"1\"><span data-contrast=\"auto\">2x and more levels of traversals will be expensive in terms of cost (RU\/s).<\/span><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Calibri Light,Times New Roman\" data-listid=\"46\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"1\" data-aria-level=\"1\"><span data-contrast=\"auto\">2x and more levels of traversals will have higher latency.<\/span><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Calibri Light,Times New Roman\" data-listid=\"46\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"1\" data-aria-level=\"1\"><span data-contrast=\"auto\">Analytical queries and aggregations are not recommended.<\/span><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Calibri Light,Times New Roman\" data-listid=\"46\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"1\" data-aria-level=\"1\"><span data-contrast=\"auto\">Complex queries which touch multiple edges out and in operation are not recommended.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<\/ol>\n<h2><b><span data-contrast=\"auto\">Conclusion<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">Using Azure Cosmos DB for NoSQL is recommended for building green-field applications. Use the information in this blog post as guidance to remodel an existing Azure Cosmos DB for Gremlin API into Azure Cosmos DB for NoSQL. It is advisable for you to test your application-specific scenarios, query access patterns<\/span><span data-contrast=\"auto\">,<\/span><span data-contrast=\"auto\"> and choose the one which provides you with the best price to performance ratio. <\/span><span data-contrast=\"auto\">Reach out to Microsoft for any specific use case guidance.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><span data-contrast=\"auto\">Let us know your thoughts or drop and specific questions in the comments section below.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h2><b><span data-contrast=\"auto\">Where to learn more<\/span><\/b><b><span data-contrast=\"auto\">.<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">Explore the following links for further information:<\/span><\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"25\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"1\" data-aria-level=\"1\"><span data-contrast=\"auto\">Azure Cosmos DB <\/span><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/nosql\/modeling-data\"><span data-contrast=\"none\">Data Modeling<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"25\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"auto\">Sample air-routes Data Model <\/span><a href=\"https:\/\/aka.ms\/azure-cosmos-gremlin-docs\"><span data-contrast=\"none\">here<\/span><\/a><span data-contrast=\"auto\"> for you to experiment<\/span><span data-contrast=\"auto\">.<\/span><\/li>\n<\/ul>\n<h2 aria-level=\"2\"><b><span data-contrast=\"auto\">About Azure Cosmos DB<\/span><\/b><\/h2>\n<p><span data-contrast=\"auto\">Azure Cosmos DB is a fully managed and serverless distributed database for modern app development, with SLA-backed speed and availability, automatic and instant scalability, and support for open-source PostgreSQL, MongoDB, and Apache Cassandra. <\/span><a href=\"https:\/\/cosmos.azure.com\/try\/\"><span data-contrast=\"none\">Try Azure Cosmos DB for free here.<\/span><\/a><span data-contrast=\"auto\"> To stay in the loop on Azure Cosmos DB updates, follow us on <\/span><a href=\"https:\/\/twitter.com\/AzureCosmosDB\"><span data-contrast=\"none\">Twitter<\/span><\/a><span data-contrast=\"auto\">, <\/span><a href=\"https:\/\/www.youtube.com\/AzureCosmosDB\"><span data-contrast=\"none\">YouTube<\/span><\/a><span data-contrast=\"auto\">, and <\/span><a href=\"https:\/\/www.linkedin.com\/company\/azure-cosmos-db\/\"><span data-contrast=\"none\">LinkedIn<\/span><\/a>.<\/p>\n<p><code><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Azure Cosmos DB is Microsoft&#8217;s premier fully managed NoSQL database for modern app development. It is ideal for solutions including artificial intelligence, digital commerce, Internet of Things, booking management and other types of use cases. It offers single-digit millisecond response times, automatic and instant scalability along with guaranteed speed at any scale. Azure Cosmos [&hellip;]<\/p>\n","protected":false},"author":93861,"featured_media":7362,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17,1611,1828,996,19],"tags":[499,1743,1896],"class_list":["post-7358","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gremlin-api","category-data-architecture","category-data-modeling","category-migration","category-tips-and-tricks","tag-azure-cosmos-db","tag-gremlin","tag-remodeling"],"acf":[],"blog_post_summary":"<p>Introduction Azure Cosmos DB is Microsoft&#8217;s premier fully managed NoSQL database for modern app development. It is ideal for solutions including artificial intelligence, digital commerce, Internet of Things, booking management and other types of use cases. It offers single-digit millisecond response times, automatic and instant scalability along with guaranteed speed at any scale. Azure Cosmos [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/7358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/93861"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=7358"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/7358\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/7362"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=7358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=7358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=7358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}