I have some document witch size 15 mb.What happen if size will be more than 16 mb? I have more nested arrays in this document (not files)? Please tell me? Thanks!
-
The provider of mongodb said: the document should not exeed 16 mb. You want to exeed, try it at your own risk. – innoSPG Apr 24 '14 at 13:29
-
16MB is the limit for the whole document with all its children. If there is a possibility that your data will outgrow this limitation, you may consider separating it to different documents/collections. – Sumit D Apr 24 '14 at 13:30
-
You could try looking into GridFS: http://docs.mongodb.org/manual/core/gridfs/ – Lalit Agarwal Apr 24 '14 at 13:53
-
possible duplicate of [MongoDB Single Document size limit is 16MB](http://stackoverflow.com/questions/15307800/mongodb-single-document-size-limit-is-16mb) – Liam May 23 '14 at 15:31
4 Answers
To answer the actual question: Operations that try to insert a document larger than 16MB or try to update an existing document in a way that makes it grow past 16MB will fail, the server will return an error.
Documents of this size are usually a sign of (very) bad design, but there are exceptions of course...

- 45,391
- 6
- 76
- 82
-
still, is there any way that I can modify the document by deleting some nested arrays and improve my design meanwhile? – Shadab Ahmed Dec 22 '19 at 23:27
-
What could be the best way to handle document size? If the document size is exceeding 16MB then can I create another document and reference it to the original one? Then what could be the consequences while accessing the whole data? – Prasanna Mar 27 '23 at 21:31
There may be cases where your document size goes beyond 16 mb. GridFS should be able to solve your problem.
Look here for reference: http://docs.mongodb.org/manual/core/gridfs/

- 2,354
- 1
- 14
- 18
You can read about the MongoDB limits here. The 16 Mb limit is for the BSON documents. As per documentation, MongoDB provides GridFS API, if you need to have them larger.
Please, keep in mind that other files should simply be stored in your CDN, or network drive, or wherever, and referenced by a simple link in your MongoDB. This way you don't necessarily need to keep your massive array in a db BSON doc, but only a reference to a file which stores it.

- 3,965
- 1
- 12
- 16
Probably GridFS is what you are looking for. This is a specification for storing and retrieving files that exceed the size limit of 16 MB.
Instead of storing a file in a single document, GridFS divides the file into parts, or chunks, and stores each chunk as a separate document.

- 2,292
- 1
- 20
- 33