What are the Cons of making Primary key or assigning unique GUID value as Partition key in Azure Cosmos DB

Ahsan Habib 126 Reputation points
2022-04-10T08:30:31.373+00:00

Lets say, I have a very huge amount of data inside of a container. I would like to assign unique GUID as value to every partition key property For that container. Now my question is,

What are the Cons of making Primary key or I can say, cons of assigning a unique GUID value to partition key property for every item inside of a container?
By very large amount, I mean the largest possible. or I can say, at what amount, we may start facing side effect, in case of making Partition key value GUID?

One disadvantage I can think of, we will be missing Transactions as it is possible within same logical partition. But in our case, every partition value is unique. What are the others?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,500 questions
{count} votes

Accepted answer
  1. Anurag Sharma 17,581 Reputation points
    2022-04-11T06:05:09.72+00:00

    Hi @Ahsan Habib , welcome to Microsoft Q&A forum.

    If I understand it correctly you want to know the disadvantages of using a unique GUID as partition key for Azure Cosmos DB Container.

    Only disadvantage here that we see will be if we don't use the partition key in our queries then they will be all cross-partition queries which are definitely costlier.

    Avoiding cross-partition queries

    There will also be no transaction as transaction scope is limited to single partition key.

    Choosing a partition key that has unique values will definitely have more pros than cons. We must always try to choose a partition key that offers more cardinality which means more range of possible value. GUID surely belongs there as it has all unique values. Another thing to mention is each partition key in this case will have a unique logical partition however this does not have any impact on performance and any other feature of cosmos db.

    Advantages:

    1. Good cardinality as wide range of values available
    2. It will help us to avoid transactions
    3. Even balancing of RU consumption of partition, which would help us in avoiding hot partitions.
    4. Faster reads, so less RU charges

    Although designing the partition key will altogether be a different topic in case you want to discuss that we well.

    Please let us know if this helps or else we can discuss further on the same.

    ----------

    If answer is helpful please click on 191741-image.png as it could help other members of the Microsoft Q&A community who have similar questions and are looking for solutions. Thank you for helping to improve Microsoft Q&A!

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful