简体   繁体   English

Azure Cosmos DB - 了解分区键

[英]Azure Cosmos DB - Understanding Partition Key

I'm setting up our first Azure Cosmos DB - I will be importing into the first collection, the data from a table in one of our SQL Server databases.我正在设置我们的第一个 Azure Cosmos DB - 我将导入第一个集合,即我们的一个 SQL Server 数据库中的表中的数据。 In setting up the collection, I'm having trouble understanding the meaning and the requirements around the partition key, which I specifically have to name while setting up this initial collection.在设置集合时,我无法理解分区键的含义和要求,我在设置这个初始集合时特别需要命名。

I've read the documentation here: ( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data ) and still am unsure how to proceed with the naming convention of this partition key.我在这里阅读了文档:( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data )但仍然不确定如何继续使用此分区键的命名约定.

Can someone help me understand how I should be thinking in naming this partition key?有人可以帮我理解在命名这个分区键时我应该怎么想吗? See the screenshot below for the field I'm trying to fill in.有关我要填写的字段,请参阅下面的屏幕截图。 分区键名称

In case it helps, the table I'm importing consists of 7 columns, including a unique primary key, a column of unstructured text, a column of URL's and several other secondary identifiers for that record's URL.如果有帮助,我要导入的表由 7 列组成,包括一个唯一的主键、一列非结构化文本、一列 URL 和该记录 URL 的其他几个辅助标识符。 Not sure if any of that information has any bearing on how I should name my Partition Key.不确定这些信息是否与我应该如何命名我的分区键有任何关系。

EDIT: I've added a screenshot of several records from the table from which I'm importing, per request from @Porschiey.编辑:根据@Porschiey 的请求,我添加了要从中导入的表中的几条记录的屏幕截图。

在此处输入图像描述

I'm setting up our first Azure Cosmos DB - I will be importing into the first collection, the data from a table in one of our SQL Server databases.我正在设置我们的第一个Azure Cosmos数据库-我将导入其中一个SQL Server数据库中的表中的数据到第一个集合中。 In setting up the collection, I'm having trouble understanding the meaning and the requirements around the partition key, which I specifically have to name while setting up this initial collection.在设置集合时,我在理解分区键的含义和要求时遇到了麻烦,在设置此初始集合时,我必须特别指出这些含义和要求。

I've read the documentation here: ( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data ) and still am unsure how to proceed with the naming convention of this partition key.我在这里阅读了文档:( https://docs.microsoft.com/zh-cn/azure/cosmos-db/documentdb-partition-data ),但仍不确定如何继续使用此分区键的命名约定。

Can someone help me understand how I should be thinking in naming this partition key?有人可以帮助我了解命名此分区键的方式吗? See the screenshot below for the field I'm trying to fill in.请参阅下面的屏幕截图,以获取我要填写的字段。 分区键名称

In case it helps, the table I'm importing consists of 7 columns, including a unique primary key, a column of unstructured text, a column of URL's and several other secondary identifiers for that record's URL.如果有帮助,我要导入的表由7列组成,包括一个唯一的主键,一列非结构化文本,一列URL和该记录的URL的其他几个辅助标识符。 Not sure if any of that information has any bearing on how I should name my Partition Key.不知道这些信息是否与我应如何命名我的分区密钥有关。

EDIT: I've added a screenshot of several records from the table from which I'm importing, per request from @Porschiey.编辑:根据@Porschiey的请求,我从导入的表中添加了几条记录的屏幕快照。

在此处输入图片说明

I'm setting up our first Azure Cosmos DB - I will be importing into the first collection, the data from a table in one of our SQL Server databases.我正在设置我们的第一个Azure Cosmos数据库-我将导入其中一个SQL Server数据库中的表中的数据到第一个集合中。 In setting up the collection, I'm having trouble understanding the meaning and the requirements around the partition key, which I specifically have to name while setting up this initial collection.在设置集合时,我在理解分区键的含义和要求时遇到了麻烦,在设置此初始集合时,我必须特别指出这些含义和要求。

I've read the documentation here: ( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data ) and still am unsure how to proceed with the naming convention of this partition key.我在这里阅读了文档:( https://docs.microsoft.com/zh-cn/azure/cosmos-db/documentdb-partition-data ),但仍不确定如何继续使用此分区键的命名约定。

Can someone help me understand how I should be thinking in naming this partition key?有人可以帮助我了解命名此分区键的方式吗? See the screenshot below for the field I'm trying to fill in.请参阅下面的屏幕截图,以获取我要填写的字段。 分区键名称

In case it helps, the table I'm importing consists of 7 columns, including a unique primary key, a column of unstructured text, a column of URL's and several other secondary identifiers for that record's URL.如果有帮助,我要导入的表由7列组成,包括一个唯一的主键,一列非结构化文本,一列URL和该记录的URL的其他几个辅助标识符。 Not sure if any of that information has any bearing on how I should name my Partition Key.不知道这些信息是否与我应如何命名我的分区密钥有关。

EDIT: I've added a screenshot of several records from the table from which I'm importing, per request from @Porschiey.编辑:根据@Porschiey的请求,我从导入的表中添加了几条记录的屏幕快照。

在此处输入图片说明

I'm setting up our first Azure Cosmos DB - I will be importing into the first collection, the data from a table in one of our SQL Server databases.我正在设置我们的第一个Azure Cosmos数据库-我将导入其中一个SQL Server数据库中的表中的数据到第一个集合中。 In setting up the collection, I'm having trouble understanding the meaning and the requirements around the partition key, which I specifically have to name while setting up this initial collection.在设置集合时,我在理解分区键的含义和要求时遇到了麻烦,在设置此初始集合时,我必须特别指出这些含义和要求。

I've read the documentation here: ( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data ) and still am unsure how to proceed with the naming convention of this partition key.我在这里阅读了文档:( https://docs.microsoft.com/zh-cn/azure/cosmos-db/documentdb-partition-data ),但仍不确定如何继续使用此分区键的命名约定。

Can someone help me understand how I should be thinking in naming this partition key?有人可以帮助我了解命名此分区键的方式吗? See the screenshot below for the field I'm trying to fill in.请参阅下面的屏幕截图,以获取我要填写的字段。 分区键名称

In case it helps, the table I'm importing consists of 7 columns, including a unique primary key, a column of unstructured text, a column of URL's and several other secondary identifiers for that record's URL.如果有帮助,我要导入的表由7列组成,包括一个唯一的主键,一列非结构化文本,一列URL和该记录的URL的其他几个辅助标识符。 Not sure if any of that information has any bearing on how I should name my Partition Key.不知道这些信息是否与我应如何命名我的分区密钥有关。

EDIT: I've added a screenshot of several records from the table from which I'm importing, per request from @Porschiey.编辑:根据@Porschiey的请求,我从导入的表中添加了几条记录的屏幕快照。

在此处输入图片说明

I'm setting up our first Azure Cosmos DB - I will be importing into the first collection, the data from a table in one of our SQL Server databases.我正在设置我们的第一个Azure Cosmos数据库-我将导入其中一个SQL Server数据库中的表中的数据到第一个集合中。 In setting up the collection, I'm having trouble understanding the meaning and the requirements around the partition key, which I specifically have to name while setting up this initial collection.在设置集合时,我在理解分区键的含义和要求时遇到了麻烦,在设置此初始集合时,我必须特别指出这些含义和要求。

I've read the documentation here: ( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data ) and still am unsure how to proceed with the naming convention of this partition key.我在这里阅读了文档:( https://docs.microsoft.com/zh-cn/azure/cosmos-db/documentdb-partition-data ),但仍不确定如何继续使用此分区键的命名约定。

Can someone help me understand how I should be thinking in naming this partition key?有人可以帮助我了解命名此分区键的方式吗? See the screenshot below for the field I'm trying to fill in.请参阅下面的屏幕截图,以获取我要填写的字段。 分区键名称

In case it helps, the table I'm importing consists of 7 columns, including a unique primary key, a column of unstructured text, a column of URL's and several other secondary identifiers for that record's URL.如果有帮助,我要导入的表由7列组成,包括一个唯一的主键,一列非结构化文本,一列URL和该记录的URL的其他几个辅助标识符。 Not sure if any of that information has any bearing on how I should name my Partition Key.不知道这些信息是否与我应如何命名我的分区密钥有关。

EDIT: I've added a screenshot of several records from the table from which I'm importing, per request from @Porschiey.编辑:根据@Porschiey的请求,我从导入的表中添加了几条记录的屏幕快照。

在此处输入图片说明

I'm setting up our first Azure Cosmos DB - I will be importing into the first collection, the data from a table in one of our SQL Server databases.我正在设置我们的第一个Azure Cosmos数据库-我将导入其中一个SQL Server数据库中的表中的数据到第一个集合中。 In setting up the collection, I'm having trouble understanding the meaning and the requirements around the partition key, which I specifically have to name while setting up this initial collection.在设置集合时,我在理解分区键的含义和要求时遇到了麻烦,在设置此初始集合时,我必须特别指出这些含义和要求。

I've read the documentation here: ( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data ) and still am unsure how to proceed with the naming convention of this partition key.我在这里阅读了文档:( https://docs.microsoft.com/zh-cn/azure/cosmos-db/documentdb-partition-data ),但仍不确定如何继续使用此分区键的命名约定。

Can someone help me understand how I should be thinking in naming this partition key?有人可以帮助我了解命名此分区键的方式吗? See the screenshot below for the field I'm trying to fill in.请参阅下面的屏幕截图,以获取我要填写的字段。 分区键名称

In case it helps, the table I'm importing consists of 7 columns, including a unique primary key, a column of unstructured text, a column of URL's and several other secondary identifiers for that record's URL.如果有帮助,我要导入的表由7列组成,包括一个唯一的主键,一列非结构化文本,一列URL和该记录的URL的其他几个辅助标识符。 Not sure if any of that information has any bearing on how I should name my Partition Key.不知道这些信息是否与我应如何命名我的分区密钥有关。

EDIT: I've added a screenshot of several records from the table from which I'm importing, per request from @Porschiey.编辑:根据@Porschiey的请求,我从导入的表中添加了几条记录的屏幕快照。

在此处输入图片说明

I'm setting up our first Azure Cosmos DB - I will be importing into the first collection, the data from a table in one of our SQL Server databases.我正在设置我们的第一个Azure Cosmos数据库-我将导入其中一个SQL Server数据库中的表中的数据到第一个集合中。 In setting up the collection, I'm having trouble understanding the meaning and the requirements around the partition key, which I specifically have to name while setting up this initial collection.在设置集合时,我在理解分区键的含义和要求时遇到了麻烦,在设置此初始集合时,我必须特别指出这些含义和要求。

I've read the documentation here: ( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data ) and still am unsure how to proceed with the naming convention of this partition key.我在这里阅读了文档:( https://docs.microsoft.com/zh-cn/azure/cosmos-db/documentdb-partition-data ),但仍不确定如何继续使用此分区键的命名约定。

Can someone help me understand how I should be thinking in naming this partition key?有人可以帮助我了解命名此分区键的方式吗? See the screenshot below for the field I'm trying to fill in.请参阅下面的屏幕截图,以获取我要填写的字段。 分区键名称

In case it helps, the table I'm importing consists of 7 columns, including a unique primary key, a column of unstructured text, a column of URL's and several other secondary identifiers for that record's URL.如果有帮助,我要导入的表由7列组成,包括一个唯一的主键,一列非结构化文本,一列URL和该记录的URL的其他几个辅助标识符。 Not sure if any of that information has any bearing on how I should name my Partition Key.不知道这些信息是否与我应如何命名我的分区密钥有关。

EDIT: I've added a screenshot of several records from the table from which I'm importing, per request from @Porschiey.编辑:根据@Porschiey的请求,我从导入的表中添加了几条记录的屏幕快照。

在此处输入图片说明

I'm setting up our first Azure Cosmos DB - I will be importing into the first collection, the data from a table in one of our SQL Server databases.我正在设置我们的第一个Azure Cosmos数据库-我将导入其中一个SQL Server数据库中的表中的数据到第一个集合中。 In setting up the collection, I'm having trouble understanding the meaning and the requirements around the partition key, which I specifically have to name while setting up this initial collection.在设置集合时,我在理解分区键的含义和要求时遇到了麻烦,在设置此初始集合时,我必须特别指出这些含义和要求。

I've read the documentation here: ( https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data ) and still am unsure how to proceed with the naming convention of this partition key.我在这里阅读了文档:( https://docs.microsoft.com/zh-cn/azure/cosmos-db/documentdb-partition-data ),但仍不确定如何继续使用此分区键的命名约定。

Can someone help me understand how I should be thinking in naming this partition key?有人可以帮助我了解命名此分区键的方式吗? See the screenshot below for the field I'm trying to fill in.请参阅下面的屏幕截图,以获取我要填写的字段。 分区键名称

In case it helps, the table I'm importing consists of 7 columns, including a unique primary key, a column of unstructured text, a column of URL's and several other secondary identifiers for that record's URL.如果有帮助,我要导入的表由7列组成,包括一个唯一的主键,一列非结构化文本,一列URL和该记录的URL的其他几个辅助标识符。 Not sure if any of that information has any bearing on how I should name my Partition Key.不知道这些信息是否与我应如何命名我的分区密钥有关。

EDIT: I've added a screenshot of several records from the table from which I'm importing, per request from @Porschiey.编辑:根据@Porschiey的请求,我从导入的表中添加了几条记录的屏幕快照。

在此处输入图片说明

You are defining a logical partition.您正在定义一个逻辑分区。 Underneath, physically the data is split into physical partitions by Azure.在下面,Azure 将数据在物理上拆分为物理分区。

Ideally a partitionKey should be a primary Key, or a field with high cardinality to ensure proper distribution, with the self generated id field within that partition also set to the primary key, that will help with documentFetchById much faster.理想情况下,partitionKey 应该是主键,或者具有高基数的字段以确保正确分配,并且该分区内的自生成 id 字段也设置为主键,这将有助于 documentFetchById 更快。

You cannot change a partitionKey once container is created.创建容器后,您无法更改 partitionKey。

Looking at the dataset, captureId is a good candidate for partitionKey, with id set manually to this field, and not an auto generated cosmos one.查看数据集,captureId 是 partitionKey 的一个很好的候选者,其中 id 手动设置到该字段,而不是自动生成的 cosmos 。

There is documentation available from Microsoft about partition keys. Microsoft 提供了有关分区键的文档。 According to me you need to check the queries or operations that you plan to perform with cosmos DB.根据我的说法,您需要检查您计划使用 cosmos DB 执行的查询或操作。 Are they read-heavy or write-heavy?它们是重读还是重写? if read heavy it is ideal to choose a partition key in the where clause that will be used in the query, if it is a write heavy operation then look for a key which has high cardinality如果读取繁重,最好在 where 子句中选择将在查询中使用的分区键,如果是写入繁重的操作,则查找具有高基数的键

Always point reads /writes are better since it consumes way less RU's than running other queries总是点读/写更好,因为它消耗的 RU 比运行其他查询要少

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM