简体   繁体   中英

How do I create a Cosmos DB container with a single partition?

I have a container that stores ~5000 documents. Each document is not very large. The most frequent query is just to select everything in this container (so that the frontend can display it in a nice table client-side). Each document has a unique ID. I was using this as the partition key ( /id ) for the container but I have read that querying data like this is more efficient in terms of time and RU/s when all the data comes from the same partition as I can avoid cross-partition queries.

Can I create a container without a partition key? Or a container that only has one partition? Will I have to add a property to every document that is the same value to force this or is there an easier way?

The number of partitions of a container is defined by the provisioned RU and data size: https://docs.microsoft.com/azure/cosmos-db/partitioning-overview#physical-partitions

So, if you create a container with less than 10K RU and keep the data size small (<50GB), it should be a single physical partition.

If you use a single value for your Partition Key, you will hit the data cap: https://docs.microsoft.com/azure/cosmos-db/sql/troubleshoot-forbidden#partition-key-exceeding-storage because your database simply won't be able to scale.

Looking at the no of documents in your container (~5000), it would ideally land in a single physical partition unless you have huge amount of RU requirement above 10,000 RU's. Assuming you have an RU config of less than 10,000 RU/S, this would be in a single physical partition >You can confirm this by looking at the metric(classic) option from the left-hand blade in the portal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM