Purpose of a Partition Key for a Cosmos DB Fixed (10GB) Collection

流过昼夜 提交于 2020-01-30 05:54:26

问题


In the Cosmos DB docs, I see that allocating a Fixed (10GB) Collection means that there will only ever be a single partition allocated to hold documents within the Collection.

My question: if I choose a Fixed Collection, why am I still prompted to choose a partition key if I will only ever have a single partition?

My guess is that the single partition refers to a single physical partition, but it is still possible to store N logical partitions (each identified by a partition key) within the single physical partition. But if this is correct, I do not see any advantages to choosing a Fixed (10GB) partition over an Unlimited partition aside from the minimum RU/s required for each.


回答1:


When we create partitioned collection we are dealing with "logical partitions" not physical ones, the physical partitions is managed by the Cosmos service.

For "Should I partition my collection?" question, in this blog, you can find:

  • Single-partition collections: have lower price options and the ability to execute queries and perform transactions across all collection data. They have the scalability and storage limits of a single partition (10GB and 10,000 RU/s). You do not have to specify a partition key for these collections. For scenarios that do not need large volumes of storage or throughput, single partition collections are a good fit.
  • Partitioned collections: can span multiple partitions and support very large amounts of storage and throughput. You must specify a partition key for these collection.



回答2:


@Rob : When you create a "fixed" 10 GB partition, there is only one physical partition allocated, whether you provide a partition key or not. Note that providing a partition key in this case is optional.

If you have provided a partition key while creating this "fixed" collection, there is a migration path for this collection to a partitioned collection and you would not have to change your application code.

If you don't provide the partition key, we don't support migration of this collection to a partitioned collection and hence you will be stuck with 10GB and you would have to manually migrate your data using our data Migration Tool to a new partitioned collection, if you ever cross the 10GB limit. Also, this would require you to change your application code(to pass in the partition key in various APIs) once you start targeting a partitioned collection.

In summary, you are well off providing a partition key while creating this "fixed" collection, even though all partition key values will be mapped to the single partition.

Hope that answers you query. Let me know if you have any more comments.

  • Rajesh, Azure Cosmos DB


来源:https://stackoverflow.com/questions/46017040/purpose-of-a-partition-key-for-a-cosmos-db-fixed-10gb-collection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!