What happens to documents in documentDb that have no partition key property?

心已入冬 提交于 2021-02-07 18:18:42

问题


Looking at how to set up DocumentDb with a partition key, if I have a multi-tenant application, where most documents have a tenantId, it seems reasonable to create the collection with a partition key of /tenantId/.

What happens to documents that don't have a tenantId property? Will they just get added without one, or will Cosmos DB create those objects/documents with some kind of system (hard-coded) tenantId, so they are stored together?


回答1:


These documents are automatically assigned the "undefined" value for partition key (similar to JavaScript's undefined). This is treated like any other value, and all documents with missing keys are stored within the same partition. If you have a large number of these, then you would have trouble scaling as all writes within missing keys would get assigned to the same partition.

It's generally a good idea to avoid this, or fix this later by deleting/reinserting (if this lack of partition key is due to some asynchronous nature of not knowing the partition key at creation time).



来源:https://stackoverflow.com/questions/46617456/what-happens-to-documents-in-documentdb-that-have-no-partition-key-property

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