Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 955
Ashwin Gopi Krishna Avatar asked Jun 18 '26 16:06

Ashwin Gopi Krishna


1 Answers

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

like image 79
Atish Avatar answered Jun 21 '26 20:06

Atish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!