Identify cross partition query in CosmosDB - azure-cosmosdb

How do I check if a query is a cross partition query from the Azure Diagnostic Logs? I have enabled the full-text logging but I don't see a flag in any of the tables displaying it as a Cross partition query
I am referring to this way of enabling the diagnostic logging in cosmos DB
https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/diagnostic-queries-mongodb?tabs=resource-specific
Thanks
Guru

Unfortunately, there is no such feature available in Azure Diagnostic Logs which can identify cross partition query in CosmosDB.

Related

Azure Cosmos settings history

Is it possible to review the history of changes to the setting of an Azure Cosmos database. I believe I am colliding with another them who is using the same Cosmos database. I would like to review all the setting that have changed since the database was created. Is that possible?
You can audit control plane operations for any Cosmos DB resource once it has been created. However, the account must be configured such that all control plane operations are done against the Cosmos DB resource provider and not through one of the data plane SDKs. See the link for details on this.
However, ARM does not support providing information on when a resource was created. This is a limitation of ARM, not Cosmos DB.
If you just wanna watch who did operations on your cosmos database, I think 'Activity Log' tab could help you. It records some message like screenshot below.
But I found that I can't get the details of the operations such as changing RU. By the way, I didn't find any documents saying how to review operations in cosmosdb. Or maybe you can provide more details about what information you wanna get from cosmosdb?

Where do I set a partitionKey in CosmosDB deployed as a Gremlin instance?

I have several Vertices and Edges to create and think I might have "hot" sections of data. (as in Azure Table Storage)
Are my scalability and other knowledge from Azure Tables applicable to Gremlin on Azure? If so, how?
Namely, I want to have "subdivided slices" of sub-tenants (or user partitions) on the database. (If possible I might want to reference between them, or query both at the same time)
Scalability and performance of any Azure Cosmos DB API is based on partitioning. Same concept is applicable for Azure Cosmos Gremlin API. While creating a graph you need to define the partition key and partitions will be created based on that.
On top of it, you can go through below article that mentions few more optimization that can help with scalability and performance. As per the article, "Queries that obtain data from a single partition provide the best possible performance."
https://learn.microsoft.com/en-us/azure/cosmos-db/graph-partitioning

Is it still a good idea to create comos db collection without partition key?

One colleague said that cosmos db will stop supporting collections without a partition key. But I can't find any information about this statement from Microsoft.
The application I'm working on has a collection of order records. A typical query returns 10s of thousands of these records. So if I use order id as partition key, it'll always run cross partition queries.... And the requirement is to get all records across all tenants, so partition by tenant id isn't an option, either.
I thought it'll be fine just create a collection without a partition key. I'll worry about archiving data later (probably with azure functions and change feed).
Is it a good idea to do so?
One colleague said that cosmos db will stop supporting collections
without a partition key. But I can't find any information about this
statement from Microsoft.
Based on the tips on the cosmos db portal,this message is confined to portal only so far.
You still could create non-partitioned collection by using sdk:
DocumentCollection collection = new DocumentCollection();
collection.set("id","jay");
ResourceResponse<DocumentCollection> createColl = client.createCollection("dbs/db",collection,null);
So,i think your service will not be affected by now. As for future trends, I suggest you pay more attention to Microsoft's official statement. If you have any special needs, you can submit feedback for help.

is there any query profiler in cosmos db?

I'm a newbie at cosmos db. and i'll be glad if someone help me to find how to catch queries that are going on local emulator. the reason why i'm asking is that now query string is appended in a few steps via linq and i need to be sure that query builder returns correct query string.
thanks in advance!
By the sound of it you are using the C# SDK and LINQ to query your database.
Once your LINQ query is ready you should be doing queryable.AsDocumentQuery() to generate a DocumentQuery object and the use that to do while(documentQuery.HasMoreResults) documentQuery.ExecuteNextAsync<yourtype>().
If that's not the case then you are using the SDK in an non optimal way.
All you need to do to get the generated SQL query is to do a .ToString() on the documentQuery object and you gonna get the translated query back.
In order to see the interactions between your application and Cosmos DB database, you can use Cosmos DB Profiler tool. It shows queries that are sent to Cosmos DB and stacktrace of relevant code that generated them.
The profiler shows statistics for each operation like duration, response status code, query execution metrics etc and also the request units for each request to a database what allows to optimize query costs.
It also alerts users about common pitfalls when using Cosmos DB and recommends how to resolve them.
Available reports provided by the profiler allow to analyze Cosmos DB usage by an application.

Getting the size of each partition in a CosmosDB collection

Is it possible to get the size of every partition in a Cosmos DB collection? I know the portal will show the top few partitions in a collection, in the Metrics blade, but I'm interesting in seeing the size of every partition.
I believe you should be able to get this data through the Cosmos DB REST API.
It doesn't seem to be exposed through the .NET SDK so you'd need to write some C# or PowerShell yourself to access the data however, it should be available.
Link is:
https://learn.microsoft.com/en-us/rest/api/cosmos-db-resource-provider/collectionpartition/listusages

Resources