c# - 如何在 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...
.
我还查看了PartitionKeyRangeStatistics但明确指出If your partition keys are below 1GB of storage, they may not show up in the reported statistics
,这适用于大多数分区。
关于如何获得集合中分区的准确计数的任何想法?
解决方案
在 Cosmosdb 中使用 Get Partition Key Ranges
API 可以检索分区键范围列表(物理分区)
推荐阅读
- elixir - 分割文件名和提取时间长生不老药
- android-studio - 未调用 ChangeNotifierProvider
- python-3.x - Python 和 Catalina 的菜单问题
- lua - 我怎样才能让这张桌子按显示的顺序排列?
- css - 在移动视图上连续显示社交图标
- java - 如何修复此程序中的编译器错误,该程序计算用户输入的字符、换行符、单词并将它们作为数组返回
- azure - Azure 管道代理无法提取工件并出现错误:不支持的媒体类型“未定义”
- python - 在特定位置查找小数的替代方法
- ios - 让 iOS 应用再次接收 VoIP 推送通知
- regex - 如何在输入 url 模式属性中使用句点后的任何字符?