本文介绍了区分分区键和Azure Cosmos DB中的分区键范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解分区键和&键之间的区别. Cosmos DB中的分区键范围.我通常了解cosmos db中的分区键是每个文档中的JSON属性/路径,用于在多个分区之间平均分配数据,以避免任何不均匀的热分区"-分区键决定文档的物理位置.

I'm having difficulty understanding the difference between the partition keys & the partition key ranges in Cosmos DB. I understand generally that a partition key in cosmos db is a JSON property/path within each document that is used to evenly distribute data among multiple partitions to avoid any uneven "hot partitions" -- and partition key decides the physical placement of documents.

但是我不清楚该分区键的范围是什么...这只是从集合中每个分区的第一个到最后一个分组的字面量分区键的范围吗?我知道可以通过对端点https://{databaseaccount}.documents.azure.com/dbs/{db-id}/colls/{coll-id}/pkranges执行GET请求来找到范围,但是只是从概念上想确保我理解.同样,对于如何细粒度地查看特定文档所属的特定分区键仍然不清楚.

But its not clear to me what the partition key range is...is this just a range of literal partition keys starting from first to last grouped by each individual partition in the collection? I know the ranges can be found by performing a GET request to the endpoint https://{databaseaccount}.documents.azure.com/dbs/{db-id}/colls/{coll-id}/pkranges but just conceptionally want to be sure I understand. Also still not clear on how to granularly view the specific partition key that a specific document belongs to.

https://docs .microsoft.com/en-us/rest/api/cosmos-db/get-partition-key-ranges

推荐答案

您在文档上定义了要用作分区键的属性.Cosmos db对集合中的所有文档散列该属性的值,并将不同的分区键映射到不同的物理分区.随着时间的流逝,您的集合将不断增长,最终可能会在5个物理分区上分布100个逻辑分区.

You define property on your documents that you want to use as a partition key.Cosmos db hashes value of that property for all documents in collection and maps different partition keys to different physical partitions.Over time, your collection will grow and you might end up having, for example, 100 logical partition distributed over 5 physical partitions.

分区键范围只是分区键的集合,这些分区键按它们映射到的物理分区分组.因此,在此示例中,您将获得5个pkrange,每个均具有min/max分区键值.

Partition key ranges are just collections of partition keys grouped by physical partitions they are mapped to.So, in this example, you would get 5 pkranges with min/max partition key value for each.

请注意,pkrange可能会更改,因为将来随着集合的增长,物理分区将被拆分,从而导致某些分区键被移至新的物理分区,从而将先前范围的一部分移至新位置.

Notice that pkranges might change because in future, as your collection grows, physical partitions will get split causing some partition keys to be moved to new physical partition causing part of the previous range to be moved to new location.

这篇关于区分分区键和Azure Cosmos DB中的分区键范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 18:47