Logical and Physical Partition Relation

George Luiz Bittencourt 21 Reputation points Microsoft Employee
2021-10-01T19:03:42.857+00:00

Hello,

I have a container with a single logical partition (LP) because I don't have a partition key defined. From the docs, I see that a LP will be assigned to only one physical partition (PP).

However, if I query this container in the CDBPartitionKeyRUConsumption table in the log analytics workspace I can see that this LP is assigned to more than on PP.
My understanding is that the PartitionKeyRangeId is the PP, so, in this case, I would see only one row from the Kusto query below. However, I am seeing several rows.

CDBPartitionKeyRUConsumption
| where DatabaseName == 'SampleDB' and CollectionName == 'Persons'
| distinct PartitionKeyRangeId

What I want to understand is what makes a LP to be assigned to more than one PP.
This information is important so we can better understand our RU usage.

Thanks for any information.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
{count} votes

1 answer

Sort by: Most helpful
  1. Anurag Sharma 17,636 Reputation points
    2021-10-05T07:04:41.393+00:00

    Thanks @GeorgeLuizBittencourt-414 for your response.

    Logical partitions are created based on the partition key value. In case we don't pass any value(null) for partition key, Cosmos DB can assign them into multiple logical containers or multiple physical partitions as nulls are treated differently than same value. Now if we talk about just a few hundred documents, chances are there that they can fall into same logical/physical partition but if there are many items they could go to different partitions.

    You can try this by creating documents with same partition key and observe they should fall into same logical partition.

    Please let us know if this helps.

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.