When to share partitions with other types/items?

Siegfried Heintze 1,861 Reputation points
2021-12-25T19:04:27.34+00:00
  1. I've been studying this article on partitioning-overview and it does not explain when to create a property and a use an invariant partition key as exemplified DocsContext.cs lines 176-178. When do we want to use invariant partition keys?
  2. When do we want to have a separate partition for each type?
  3. When do we want to store multiple types in the same partition?
  4. Supposing we have one partition key per item (that is, the partition key is the item key which uniquely identifies the item). I think this means lots of logical partitions. Please explain the time/space/$ costs for this approach of lots of logical partitions assuming we never have cross partition queries (that is, only do point read/writes).
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,443 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mark Brown - MSFT 2,761 Reputation points Microsoft Employee
    2021-12-25T19:48:11.683+00:00

    Answers

    1. In Cosmos DB a partition key is required. It is fundamental to allowing the database to scale outwards or horizontally with increasing size and throughput.
    2. There are numerous reasons for this. You may want to be able to differentiate between different entities to all you to store them in the same container. They may also have different access patterns. However, in those scenarios it's often better to just store them in a different container.
    3. If you mean when would you mix different entities within a logical partition, you would do this when the data is typically accessed together.
    4. Having lots of logical partitions is not a concern. You can have an infinite number of logical partitions. Containers where the partition key is the /id is fundamentally a key/value store.

    For people that are new to this type of database I strongly recommend watching this. It will give you a solid understanding of how to model and partition data in Cosmos DB so you can have high performance and high efficiency. https://youtu.be/3gEytt-Jops?t=1511


0 additional answers

Sort by: Most helpful