mongodb BSON size

泄露秘密 提交于 2019-12-25 13:18:19

问题


There is post on stackoverflow in which it is mentioned that BSON size limit is upto 4MB or 8MB. Well for my application the JSON documents would be hardly few tens of kilobytes or even less. Is mongodb suitable for my application if my document size is so less. What I actually want to ask is, do mongodb set aside 4 MB or 8 MB of space for every document so as to improve quick lookups. Well the question might sound stupid, but can anyone tell is it suitable for my application or not.


回答1:


No, smaller documents are perfectly fine. There is no space left aside to make a document fit into mega-byte-sized chunks.

MongoDB will leave a little bit of padding to allow for documents to allow for in-place updates even when documents grow, but that is not very much. Other than that, the on-disk space requirement for the document is just the BSON size of the data itself.




回答2:


First off this is not a BSON limit but a mongodb limit, and is currently 16 mb.

As that link explains, the limit is largely a sanity check to stop you from doing anything too crazy. It certainly isn't the case that smaller documents are padded to reach that size.

Mongodb does pad documents slightly but only so that updates (which might grow the document) can happen in place reasonably often.



来源:https://stackoverflow.com/questions/10061115/mongodb-bson-size

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