How does the data size limitation work?

Hi all,

I’ve learned that there’s a data size limitation of 16 MB,

and a limitation on number of documents in the documents array for insert command. ref

Also, It seems like there’s a mechanism that will divide the operations that exceed the limit internally, ref

then I’d like to ask will the limitation still be against if the mechanism divide the operations into small groups?


Hello @xc44xc44xc,

You can use the db.collection.insertMany method for inserting multiple documents into a collection.

I dont think there is any specified limit for the input document array - it can be 10000, or 100000 or 1000000, etc.

See Execution of Operations on details about how MongoDB groups the documents into smaller batches when inserting many documents.

It looks like you had linked an older version of MongoDB v4.0 documentation - the current version is 5.0 (and my above links for documentation are for 5.0).

Yes, the individual document size limit is 16 Megabytes.

Thank you for replying!

but one thing that still confuses me is that will the 16 mb limit be against even though MongoDB automatically separates documents into small groups?

I mean, if a document or documents were divided into smaller groups, which have less data size than 16 mb,

then it seems like the 16 mb limit will never be a problem?

In MongoDB. there are databases, and collections within a database and documents within a collection. The 16 MB limit is for each document.

When you do a insertMany the array passed as an argument to the method holds multiple documents - each array element is a document. The dividing into smaller groups is the number of documents.

Each document is not divided into smaller ones.



I got it,

Thanks for answering :grinning: !

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.