我使用 GUID Id 作为分区键,当我尝试运行存储过程时遇到问题。要运行存储过程,我需要提供分区键,但我不确定在这种情况下应该提供什么值?请帮忙。
最佳答案
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.
您可以引用上面的描述,提到here 。
正如 @Rafat Sarosh 所说,GUID Id
不是合适的分区键
。根据您的情况,city
可能更合适。您可能需要调整数据库分区方案
,因为分区键定义后无法删除或修改。
我建议你exporting your data到 json
文件,然后 import通过 Azure Cosmos DB Data migration tool 到按 city
分区的新集合.
希望对您有帮助。
<小时/>仅供总结:
问题:
执行sql查询文档时无法提供特定的分区键值。
解决方案:
1.执行查询sql时将EnableCrossPartitionQuery
设置为true
。(有性能瓶颈)
2.考虑将经常查询的字段设置为分区键。
关于Azure Cosmos DB 要求提供存储过程的分区键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48798523/