Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting more than 16mb document into Mongo db 3.0 using java

I've been evaluating Mongo db 3.0 in java and encountered a scenario where in the document size has exceeded 16MB. The scenario is such that I've a list of primary keys(unique records) which should be in a document as embedded collection with some additional fields. When the pk's exceed 16k, we get the error saying the document size has been exceeded. I know that we can keep the collection outside of the document instead of embedding it, but since it is required in our scenario we have it this way. If we keep it outside of the document as a separate collection, it works fine, but the inserts/updates are becoming very very slow since it has to search all the pk's and the insert/update.

Is there any other way we can accomplish this?

I know that we can use gridfs for this, but as I've seen the examples it is mainly used for storing the images/videos etc in a file system. This is certainly not how we want to do it.

Any suggestions would be very helpful!!! Thanks in Advance.

like image 269
Shaik Mujahid Ali Avatar asked Oct 01 '15 11:10

Shaik Mujahid Ali


1 Answers

Here is the official documentation :

MongoDB Limits and Thresholds

They suggest also to use GridFS when you exceed the size limit of BSON object(16 mbytes). GridFS is not only used for media files, but all kind of binary content.

like image 101
Romain Schlick Avatar answered Oct 26 '22 18:10

Romain Schlick