azureazure-cosmosdbpartitioningazure-cosmosdb-mongoapi

Partition Key Vs Document Id in CosmosDB


If I store documents without providing partition key, In this case documentId will be treated as Partition Key of Logical Partition?

If yes: how about Billion logical partitions in that collection? I have query to only look by documentId.

Now inside Document JSON:
I have multiple fields & I have provided /asset as the partitionKey. Is this a composite partition key now: /asset/documentId? or /asset will tel partition to search for documentId from?

enter image description here


Solution

  • If I store documents without providing partition key, In this case documentId will be treated as Partition Key of Logical Partition?

    No. If you create a document without Partition Key, document id will not be treated as the partition key. Cosmos DB engine will put all the documents without a partition key value in a hidden logical partition. This particular partition can be accessed by specifying partition key as {}.