mongoDB Index Limits

徘徊边缘 提交于 2019-12-24 19:25:18

问题


I am currently working with mongoDB trying to index quite a large database. It has a field in every document called "content" that is of varying length. I have tried indexing it once, it ran for 2 hours, completed the indexing, but didn't build it because it came across something larger than 1024 bytes. I tried reading the limits manual, but I am not sure I 100% understand what these limits mean. Is it the "content" field that can be max 1024 bytes? Like so:

{ "Content" : "Can this be max 1024 bytes?" }

Or have I completely misunderstood this?

https://docs.mongodb.com/manual/reference/limits/


回答1:


The documentation says:

The total size of an index entry, which can include structural overhead depending on the BSON type, must be less than 1024 bytes.

You are indexing the values of the field "Content" so you understood it right. Each value of the field "Content" has to stay below 1024 bytes per indexed document.

Some bytes are reserved depending on the data type to store meta values. For example ff the value is a String, the length and the enconding are overhead values that also need to fit into the 1024 bytes so you have less remaining bytes your actual content. So try to stay below 1000 bytes to be save.

{ "Content" : "this value must stay below 1024 bytes!" }


来源:https://stackoverflow.com/questions/45653676/mongodb-index-limits

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