{"id":4706,"date":"2022-08-16T08:00:40","date_gmt":"2022-08-16T15:00:40","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=4706"},"modified":"2022-09-19T13:56:54","modified_gmt":"2022-09-19T20:56:54","slug":"azure-cosmos-db-sql-studio-is-a-hidden-gem","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/azure-cosmos-db-sql-studio-is-a-hidden-gem\/","title":{"rendered":"Azure Cosmos DB SQL Studio is a Hidden Gem!"},"content":{"rendered":"<p><span style=\"font-style: normal !msorm;\"><em>This post was authored by Microsoft MVP and Azure Cosmos DB <\/em><\/span><em>c<span style=\"font-style: normal !msorm;\">ommunity champion Hasan Savran.\u00a0 You can reach Hasan <\/span>(@SavranWeb) <span style=\"font-style: normal !msorm;\">on <\/span><\/em><a href=\"https:\/\/twitter.com\/SavranWeb\/\">Twitter<\/a><span style=\"font-style: normal !msorm;\"><em>.\u00a0 <\/em><\/span><\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/sql\/\">Azure Cosmos DB Core (SQL) API<\/a> has many features that can help you with your cloud projects in Microsoft Azure. Most of these features; especially the new ones are at the SDK level, and you need to know .NET or Java language to access them.<\/p>\n<p>I developed the extension for all levels of users within the Azure Cosmos DB community. It is a user-friendly, free tool that is not browser-based and doesn\u2019t require you to know C# or Java to interact with Azure Cosmos DB. Azure Cosmos DB SQL Studio is a free VSCode extension you can download directly from the VSCode Extensions tab or the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=SavranWeb.cosmosdbsqlapi\">VSCode Marketplace website<\/a>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-4726\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode1.png\" alt=\"Visual Studio Code Extensions\" width=\"780\" height=\"419\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode1.png 780w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode1-300x161.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode1-768x413.png 768w\" sizes=\"(max-width: 780px) 100vw, 780px\" \/><\/a><\/p>\n<p>In this article, we will walk though setting up and using the Azure Cosmos DB SQL Studio tool to:<\/p>\n<ul>\n<li><span style=\"text-decoration: underline;\"><a href=\"#startusing\"><span style=\"font-weight: normal !msorm;\"><strong>Start using the extension<\/strong><\/span><\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"#connect\"><span style=\"font-weight: normal !msorm;\"><strong>Connect to your Azure Cosmos DB account<\/strong><\/span><\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"#runquery\"><span style=\"font-weight: normal !msorm;\"><strong>Run a query<\/strong><\/span><\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"#pointread\"><b>Point Read Operations<\/b><\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"#indexingmetrics\"><strong>Enabling Indexing Metrics<\/strong><\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"#data\"><strong>Analyzing Data<\/strong><\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"#perftuning\"><b>Performance Tuning<\/b><\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"#spatial\"><b>Configuring Spatial Data Options<\/b><\/a><\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"font-weight: normal !msorm;\"><strong><a id=\"startusing\"><\/a>Start using the extension<\/strong><\/span><\/p>\n<p>If you are new to VSCode, you need to know how to start\/use an extension. Press Ctrl + Shift + P and find Azure Cosmos DB SQL Studio from the list to start the extension.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode2.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4709\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode2-1024x550.jpg\" alt=\"Visual Studio Code Command Palatte\" width=\"640\" height=\"344\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode2-1024x550.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode2-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode2-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode2-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode2.jpg 1919w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h5><span style=\"font-weight: normal !msorm;\"><strong><a id=\"connect\"><\/a>Connect to your Azure Cosmos DB account<\/strong><\/span><\/h5>\n<p>After you select the Azure Cosmos DB SQL Studio, you will see the following screen. This screen asks you how you would like to connect to your Azure Cosmos DB account. The first option \u201cConnect by VsCode Azure Account\u201d uses the VSCode Azure extension and a token to get access to your account. This option works well if you are the owner of the Azure subscription, if you do not own the subscription, you might not have the rights to run some of the functions it requires. I suggest you use the second option, copy and paste any of your connection strings from the Azure Portal to the textbox and click on the Connect button to continue. The application does not have write functionality so you can use the read-only keys if you like.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode3.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4710\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode3-1024x550.jpg\" alt=\"Connect to your Azure Account with VS Code\" width=\"640\" height=\"344\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode3-1024x550.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode3-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode3-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode3-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode3.jpg 1919w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>You should see all your databases and containers on the top. You can easily find how many physical partitions a container has by clicking the Partition List button. You will see a list in a popup window. In the following example, the selected container has 5 physical partitions. If you do not include the partition key of your container in your queries, Azure Cosmos DB will run your query in 5 physical partitions.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode4.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4711\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode4-1024x549.jpg\" alt=\"Azure Cosmos DB will run your query in 5 physical partitions\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode4-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode4-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode4-768x411.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode4-1536x823.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode4.jpg 1919w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h5><span style=\"font-weight: normal !msorm;\"><strong><a id=\"runquery\"><\/a>Run a query<\/strong><\/span><\/h5>\n<p>To run a query, type your query and click on the Execute button. You will see the Request Charge and the Number of items in the middle section.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode5.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4712\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode5-1024x549.png\" alt=\"Request Charge and the Number of items in\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode5-1024x549.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode5-300x161.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode5-768x412.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode5-1536x824.png 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode5.png 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>You can see execution Metrics by clicking on the tab to the right side of the results. There are two numbers here you should watch closely. Retrieved Documents value and Index Hit Documents value should be equal or very close to each other. The gap between these two numbers tells you that there might be some opportunities to make your query faster\/cheaper. Usually, you fix this problem by changing your indexing policies.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode6.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4713\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode6-1024x548.jpg\" alt=\"Execution Metrics\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode6-1024x548.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode6-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode6-768x411.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode6-1536x822.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode6.jpg 1919w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Your query might need to retrieve data from multiple physical partitions if you do not include the partition key of the selected container in the query. You can see each physical partition\u2019s execution plan by clicking on the link for the Number of Requests property.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode7.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4714\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode7-1024x549.jpg\" alt=\"Number of Requests property\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode7-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode7-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode7-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode7-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode7.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>You can easily look at the current indexing policy for the selected container by clicking on the Indexing Policy tab.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode8.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4715\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode8-1024x549.jpg\" alt=\"Indexing Policy Tab\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode8-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode8-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode8-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode8-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode8.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<h5><\/h5>\n<h5><strong><a id=\"pointread\"><\/a>Point Read Operations<\/strong><\/h5>\n<p>Azure Cosmos DB SQL Studio lets you make Point Read calls. You can reach this functionality by clicking on the Point Read tab. To make a Point Read call, you must pass the partition key value and the document id of the document. By giving these two values you are telling Azure Cosmos DB exactly where to find the data you are looking for. Azure Cosmos DB does not need to create a query execution plan for this request. Since you use fewer resources for Point Read operation, you will get charged fewer Request Units (RUs). In the following example, this point read operation costs only 1 R\/U.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode9.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4716\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode9-1024x549.jpg\" alt=\"Point Read Operations\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode9-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode9-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode9-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode9-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode9.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h5><strong><a id=\"indexingmetrics\"><\/a>Enabling Indexing Metrics<\/strong><\/h5>\n<p>The Indexing Metrics is another great feature of Azure Cosmos DB. You can see which indexes are getting used by queries and find out if Azure Cosmos DB suggests you create new indexes for your queries. This is not an easy feature to demonstrate, especially if you don\u2019t know how to code. You can easily run this feature by checking the Display Indexing Metrics in Options. This will make the Indexing Metrics tab available beside the Results tab.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode10.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4717\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode10-1024x549.jpg\" alt=\"Enabling Indexing Metrics\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode10-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode10-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode10-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode10-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode10.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Azure Cosmos DB Indexing Engine communicates via the Indexing Metrics feature. It analyzes your query and suggests indexes. It does not analyze your data when it makes these suggestions. Test these suggestions before you try to put them into any production indexing policy. The following example shows Indexing Metrics in action, as you can see the WHERE clause has many filters and Azure Cosmos DB suggests me a Composite Index.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode11.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4718\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode11-1024x549.jpg\" alt=\"Composite Index Suggestion\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode11-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode11-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode11-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode11-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode11.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h5><strong><a id=\"data\"><\/a>Analyzing Data<\/strong><\/h5>\n<p>Sometimes, you may need to analyze the data returned by a query. \u00a0This can be a challenge since returned data is in JSON format. The data Analyzer tab will help you with simple analysis requirements. It supports three types of charts. To visualize the data, \u00a0define the x-axis and y-axis with two dropdowns. \u00a0At the bottom of the charts, Data Analyzer gives you simple stats of selected properties.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode12.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4719\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode12-1024x549.jpg\" alt=\"Analyzing Data\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode12-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode12-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode12-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode12-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode12.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h5><strong><a id=\"perftuning\"><\/a>Performance Tuning<\/strong><\/h5>\n<p>The process of improving query performance usually requires tracking query execution plans. By tracking this information, you can see if the changes you make in a query help the performance of a query. The Query Analyzer tracks the queries, execution plans, and indexing metrics of queries. You can easily compare queries to figure out what has changed. In the following example, you can see Query Analyzer in action. You need to click the Start button for Query Analyzer to start tracking query execution. From that point, you will see each executed query\u2019s important execution metrics properties side by side.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode13.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4720\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode13-1024x549.jpg\" alt=\"Performance Tuning\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode13-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode13-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode13-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode13-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode13.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>If you like to see the query itself or the indexing suggestions of any tracked queries, click on Compare buttons to see more details about the queries. The following screenshot shows you that there are composite index suggestions for each query. To see the suggested indexes, click the Play button to run the query again and see its Indexing Metrics. Re-executed queries will not be tracked and listed again in the Query Analyzer.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode14.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4721\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode14-1024x549.jpg\" alt=\"Re-executed queries will not be tracked and listed again in the Query Analyzer.\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode14-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode14-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode14-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode14-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode14.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h5><strong><a id=\"spatial\"><\/a>Configuring Spatial Data Options<\/strong><\/h5>\n<p>Azure Cosmos DB supports Geospatial data saved in the GeoJSON format. There are special types of indexes and functions to retrieve spatial data from Azure Cosmos DB. Use Azure Cosmos DB SQL Studio to render spatial data on a map by using the Map tab.<\/p>\n<p>To see the data on the map, you need to set spatial options first by using the Options button. There are two important options you need to set here. The First one is the Spatial Property to draw, you need to give the property name that has the spatial data in your data model. The second one is the Spatial Property to use in filters, the application lets you draw a rectangle or a custom polygon to make a search in Azure Cosmos DB. The application dynamically creates an Azure Cosmos DB spatial query in the backend, and it needs to know which property has the spatial data. Usually, both options have the same property name unless you have multiple spatial properties in your data model, and you use one for searching and use the other one for drawing.<\/p>\n<p>In the following example, Data Model has spatial data in the property named Location.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode15.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4722\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode15-1024x549.jpg\" alt=\"Image vscode15\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode15-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode15-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode15-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode15-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode15.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>We are ready to use the Map tab after this setup. I have all the hurricane information including the location in this container. I want to see the data for Katrina, so I typed a very simple query without any spatial functions in the following example. The application will use the given spatial property name to render points on the map.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode16.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4723\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode16-1024x549.jpg\" alt=\"Spatial Data\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode16-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode16-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode16-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode16-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode16.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>You can use the Draw Polygon or Draw Rectangle functions to search. In the following example, I draw a rectangle. The Application runs a query with a ST_WITHIN spatial function and displays the data under the rectangle. If you like to see the query, you can go back to Options and check the Display Spatial Queries option.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode17.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-4724\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode17-1024x549.jpg\" alt=\"Display Spatial Queries option\" width=\"640\" height=\"343\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode17-1024x549.jpg 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode17-300x161.jpg 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode17-768x412.jpg 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode17-1536x824.jpg 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2022\/08\/vscode17.jpg 1920w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>I hope you like the Azure Cosmos DB SQL Studio. I will continue to improve this application and as always I am open to feedback and suggestions.\u00a0\u00a0 Azure Cosmos DB SQL studio is available for download in the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=SavranWeb.cosmosdbsqlapi\">Visual Studio Code extensions Marketplace.<\/a><\/p>\n<p>If you\u2019d like to see more, check out the July 2022 Azure Global User Group video on YouTube for a full demonstration along with questions and answers right from our community users.\u00a0 <a href=\"https:\/\/www.meetup.com\/azure-cosmos-db-global-user-group\/\">Join the user group on Meetup.com<\/a> to see more great demonstrations from Microsoft and community members from across the globe.<\/p>\n<p><iframe src=\"\/\/www.youtube.com\/embed\/AE830jzJiSI\" width=\"560\" height=\"314\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<hr \/>\n<h5><a href=\"https:\/\/azure.microsoft.com\/services\/cosmos-db\/#overview\">About Azure Cosmos DB<\/a><\/h5>\n<p>Azure Cosmos DB is a fast and scalable cloud database for modern app development. <a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/optimize-dev-test\">See how to get started, dev\/test, and run small production workloads free.<\/a><\/p>\n<p>Get product updates, ask questions, and learn more about Azure Cosmos DB by following us on <a href=\"https:\/\/www.linkedin.com\/company\/azure-cosmos-db\/\">LinkedIn<\/a> , <a href=\"http:\/\/www.youtube.com\/AzureCosmosDB\">YouTube<\/a>, and <a href=\"https:\/\/twitter.com\/azurecosmosdb\">Twitter<\/a>.<\/p>\n<p><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/try-free\" target=\"_blank\">Try Azure Cosmos DB free<\/a><\/div><\/p>\n<hr \/>\n<h5>About Hasan<\/h5>\n<p><em>Hasan Savran is a Business Intelligence Manager at Progressive Insurance Company. He spends his days architecting cutting edge business solutions by using the latest Web and Database technologies.\u00a0 He has 15+<\/em><em>\u00a0years<\/em>\u00a0<em> of experience in Web development and Business Intelligence. He is a Microsoft Data Platform MVP, Microsoft Certified Solutions Developer and the Vice President of Ohio North SQL Server User Group. He likes to write about SQL, Azure Cosmos DB, C#, and Front End development on his <\/em><a href=\"https:\/\/h-savran.blogspot.com\/\">blog.<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post was authored by Microsoft MVP and Azure Cosmos DB community champion Hasan Savran.\u00a0 You can reach Hasan (@SavranWeb) on Twitter.\u00a0 Azure Cosmos DB Core (SQL) API has many features that can help you with your cloud projects in Microsoft Azure. Most of these features; especially the new ones are at the SDK level, [&hellip;]<\/p>\n","protected":false},"author":39313,"featured_media":4719,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-4706","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-sql-api"],"acf":[],"blog_post_summary":"<p>This post was authored by Microsoft MVP and Azure Cosmos DB community champion Hasan Savran.\u00a0 You can reach Hasan (@SavranWeb) on Twitter.\u00a0 Azure Cosmos DB Core (SQL) API has many features that can help you with your cloud projects in Microsoft Azure. Most of these features; especially the new ones are at the SDK level, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/4706","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\/39313"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=4706"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/4706\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/4719"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=4706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=4706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=4706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}