I have a loop and each time the loop iterates, it adds a record to an array.
In my current model, I wait for the loop to finish completely and then insert that array into MongoDB and have not had problems with that until now.
Now my array size is starting to exceed 10 MB after the loop and I read that Mongo has a 4MB limit. And I do not want to store the whole array into memory while I wait for the loop to finish.
Ideally, I'd love to do an update within the loop on the same Mongo Id of the collection so that I do not need to store the array in the memory. However, it seems Mongo will not support if the collection size is over 4MB so I do not know how to go about it.
I read about GridFS but I do not see a way to insert arrays using it. Any ideas would be much appreciated.
Copyright Notice:Content Author:「Subrat Basnet」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/7939909/mongodb-and-php-insert-and-update-large-php-array