Reputation: 9458
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.
Upvotes: 0
Views: 3125
Reputation: 84114
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.
Upvotes: 1
Reputation: 262484
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.
Upvotes: 1