Azure Cosmos DB asking for partition key for stored procedure

痴心易碎 提交于 2019-12-17 20:49:00

问题


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.


回答1:


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.

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.

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.

Hope it helps you.


Just for summary:

Issue:

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

Solution:

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

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




回答2:


Please take a look at this video https://youtu.be/F0wEDdxQER0?t=9m40s

Please read more on partition key here: https://docs.microsoft.com/en-us/azure/cosmos-db/partition-data



来源:https://stackoverflow.com/questions/48798523/azure-cosmos-db-asking-for-partition-key-for-stored-procedure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!