Azure Cosmos DB要求存储过程的分区键 [英] Azure Cosmos DB asking for partition key for stored procedure

查看:95
本文介绍了Azure Cosmos DB要求存储过程的分区键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将GUID Id用作分区键,并且在尝试运行存储过程时遇到问题.要运行存储过程,我需要提供分区键,但我不确定在这种情况下应提供什么值?请协助.

I am using GUID Id as my partition key and I am facing problem when I am trying to run a stored procedure. To run a store procedure I need to provide partition key ans I am not sure what value should I provide in this case? Please assist.

推荐答案

如果集合所存储的过程被注册为一个 单分区集合,则事务范围为所有 馆藏内的文件.如果集合已分区, 然后在一个存储区的事务范围内执行存储过程 单分区键.然后必须执行每个存储过程 包括与范围相对应的分区键值 交易必须在此之下进行.

If the collection the stored procedure is registered against is a single-partition collection, then the transaction is scoped to all the documents within the collection. If the collection is partitioned, then stored procedures are executed in the transaction scope of a single partition key. Each stored procedure execution must then include a partition key value corresponding to the scope the transaction must run under.

您可以参考上面提到的

You could refer to the description above which mentioned here.

正如@Rafat Sarosh所说,GUID Id不适合作为partitioning key.根据您的情况,city可能更合适.您可能需要调整数据库partitioning scheme,因为在定义分区键后无法删除或修改分区键.

As @Rafat Sarosh said, GUID Id is not an appropriate partitioning key. Based on your situation , city may be more appropriate.You may need to adjust your database partitioning scheme because the partitioning key can not be deleted or modified after you have defined it.

我建议您将数据导出json文件,然后导入到新集合,该集合由city通过

I suggest you exporting your data to json file then import to a new collection which is partitioned by city via Azure Cosmos DB Data migration tool.

希望它对您有帮助.

仅供参考:

问题:

Issue:

在执行sql查询文档时无法提供特定的分区键值.

Unable to provide specific partition key value when executing sql to query documents.

解决方案:

1.执行查询sql时将EnableCrossPartitionQuery设置为true.(存在性能瓶颈)

1.Set EnableCrossPartitionQuery to true when executing query sql.(has performance bottleneck)

2.考虑将经常查询的字段设置为分区键.

2.Consider setting a frequently queried field as a partitioning key.

这篇关于Azure Cosmos DB要求存储过程的分区键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆