Search code examples
mongodbnosqlbson

MongoDB maximum document size


As per the following link, the limit for a document size is 16MB.
https://docs.mongodb.com/manual/reference/limits/
However, I'm a little confused as to what a document is. For example,

{
 {
   "name": "test",
   "_id": "4"
 },
 {
   "name": "test2",
   "_id": "5"
}

Does the above file refer to 1 document or 2 documents? And should the size of the entire file be less than 16MB, or the size of 1 element/document?


Solution

  • In mongodb, collection stores documents.

    Every document is a JSON object stored internally as a BSON.

    Find the mongodb documentation here on document.

    In the sample data, there are two documents:

    {
       "name": "test",
       "_id": "4"
     }
    

    and

    {
       "name": "test2",
       "_id": "5"
    }
    

    Every such a document has a limit of 16MB while storing in mongodb. For storing documents size greater than 16MB consider using GridFS