且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Azure Cosmos DB要求存储过程的分区键

更新时间:2022-11-25 11:39:11

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

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.