简体   繁体   English

如何创建具有单个分区的 Cosmos DB 容器?

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

I have a container that stores ~5000 documents.我有一个存储约 5000 个文档的容器。 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.每个文档都有一个唯一的 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.我使用它作为容器的分区键( /id ),但我已经读到,当所有数据都来自同一个分区时,像这样查询数据在时间和 RU/s 方面效率更高,因为我可以避免交叉分区查询。

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容器的分区数由预配的 RU 和数据大小定义: 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.因此,如果您创建一个小于 10K RU 的容器并保持较小的数据大小(<50GB),它应该是单个物理分区。

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.如果您为分区键使用单个值,您将达到数据上限: https ://docs.microsoft.com/azure/cosmos-db/sql/troubleshoot-forbidden#partition-key-exceeding-storage 因为您的数据库根本无法扩展。

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.查看容器中的文档数量(约 5000 个),理想情况下它会放在单个物理分区中,除非您有超过 10,000 RU 的大量 RU 需求。 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假设您的 RU 配置小于 10,000 RU/S,这将位于单个物理分区中 >您可以通过查看门户左侧刀片中的 metric(classic) 选项来确认这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们如何在使用 Azure.ResourceManager.CosmosDB 1.0.1 创建 cosmos DB SQL 容器时传递 cosmos DB 分区键定义 - How do we pass cosmos DB partition key definition while creating a cosmos DB SQL Container using Azure.ResourceManager.CosmosDB 1.0.1 如何使用pydocumentdb在Cosmos DB中创建分区集合? - How do I create a partitioned collection in Cosmos DB with pydocumentdb? Azure Cosmos DB:如何为特定容器创建只读副本 - Azure Cosmos DB: How to create read replicas for a specific container 如何使用 Azure 门户在 Cosmos DB 中创建单个分区集合 - How to create single partitioned collection in Cosmos DB using Azure portal Cosmos DB的分区键 - Partition Key for Cosmos DB 如果有定期备份,我该如何恢复 Cosmos DB 容器? - How could I restore a Cosmos DB container if there is a periodic backup? 如何在 Cosmos DB 中的单个存储过程中执行多项操作 - How to do multiple operations in single stored procedure in Cosmos DB 在 C# 创建 Cosmos Db 和 Container - Create a Cosmos Db and Container in C# Cosmos DB:创建文档时如何将分区键的值设置为 id? - Cosmos DB: How to set the value of partition key to id when create a document? 如何在使用 ReadItemAsync 时只传入 Partition Key? - 宇宙数据库 - How can I only pass in Partition Key when using ReadItemAsync? - Cosmos DB
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM