简体   繁体   English

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

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

In order to tune the performance of a CosmosDB for MongoDB API, I need to get the number of partitions in a collection. 为了调整CosmosDB for MongoDB API的性能,我需要获取集合中的分区数。

The naive way of doing this would be to query for all distinct values for the partition key, like this (in C#): 这样做的简单方法是查询分区键的所有不同值,如下所示(在C#中):

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

But of course this would need to look at every single document or at least scan the whole index and fails with 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... 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...

I have also looked at the PartitionKeyRangeStatistics but that explicitly states If your partition keys are below 1GB of storage, they may not show up in the reported statistics , which applies to most of the partitions. 我还查看了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适用于大多数分区。

Any ideas on how to get an accurate count of the partitions in a collection? 有关如何准确计算集合中分区的任何想法?

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

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

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