Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle MongoDB documents with array larger than 16MB

Tags:

mongodb

There is a document with array, which size is more than 16 MB. How to store this document to be able to query some data from this array.

like image 633
madmanul Avatar asked Apr 29 '16 11:04

madmanul


1 Answers

When you have documents which exceed the 16MB limit then you are very likely taking the denormalization approach of MongoDB too far and should consider to create another collection with one document for each array entry (or one document for each sensible grouping of array entries).

Another option is to treat the content as binary data and store it as a file in GridFS, but then you won't be able to do any meaningful queries on its content (only on the metadata you write for it separately).

The 16MB limit is hardcoded. You can not change it through configuration. There was a bugtracker ticket for that and it was closed as "Won't fix". But considering that MongoDB is open source, you could always change it in the sourcecode. Just keep the license conditions in mind when you do that.

like image 172
Philipp Avatar answered Oct 20 '22 00:10

Philipp