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

查看:39
本文介绍了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.

推荐答案

如果存储过程注册的集合是一个单分区集合,那么事务的范围是所有集合中的文档.如果集合是分区的,然后在a的事务范围内执行存储过程单个分区键.然后每个存储过程执行必须包括与范围对应的分区键值事务必须在下运行.

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 不是一个合适的分区键.根据您的情况,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<分区的新集合/code> 通过 Azure Cosmos DB 数据迁移工具.

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.

希望对你有帮助.

仅供参考:

问题:

执行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天全站免登陆