[英]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.