【问题标题】:How to get the number of partitions in CosmosDB MongoDB API如何在 CosmosDB MongoDB API 中获取分区数
【发布时间】:2019-06-10 17:31:52
【问题描述】:

为了调整 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... 失败。

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

关于如何获得集合中分区的准确计数的任何想法?

【问题讨论】:

    标签: c# azure azure-cosmosdb


    【解决方案1】:

    使用 Cosmosdb 中的 GetPartition Key Ranges API 可以检索分区键范围列表(物理分区)

    【讨论】:

    • 感谢您的回答,但是我需要逻辑分区的数量,而不是物理分区。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-02
    • 1970-01-01
    • 2020-03-05
    • 1970-01-01
    • 2021-09-17
    • 1970-01-01
    相关资源
    最近更新 更多