繁体   English   中英

如何获取CosmosDB MongoDB API中的分区数量

[英]How to get the number of partitions in CosmosDB MongoDB API

为了调整CosmosDB for MongoDB API的性能,我需要获取集合中的分区数。

这样做的简单方法是查询分区键的所有不同值,如下所示(在C#中):

var results = await SomeCollection.Distinct<string>("PartitionKey", filter: "{}").ToListAsync();

但是当然这需要查看每个文档或者至少扫描整个索引并且失败, Query exceeded the maximum allowed memory usage of 40 MB. Please consider adding more filters to reduce the query response size... Query exceeded the maximum allowed memory usage of 40 MB. Please consider adding more filters to reduce the query response size...

我还查看了PartitionKeyRangeStatistics但明确说明If your partition keys are below 1GB of storage, they may not show up in the reported statistics ,这些If your partition keys are below 1GB of storage, they may not show up in the reported statistics适用于大多数分区。

有关如何准确计算集合中分区的任何想法?

在Cosmosdb中使用获取Partition Key Ranges API您可以检索分区键范围列表(物理分区)

暂无
暂无

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

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