MongoDB: mongoimport loses connection when importing big files

I guess the problem is about performance, any way you can solved used:

you can use mongoimport option -j. Try increment if not work with 4. i.e, 4,8,16, depend of the number of core you have in your cpu.

mongoimport --help

-j, --numInsertionWorkers= number of insert operations to run concurrently (defaults to 1)


mongoimport -d mietscraping -c mails -j 4 < mails.json


or you can split the file and import all files.

I hope this help you.


looking a little more, is a bug in some version https://jira.mongodb.org/browse/TOOLS-939 here another solution you can change the batchSize, for default is 10000, reduce the value and test:

mongoimport -d mietscraping -c mails < mails.json --batchSize 1

Tags:

Mongodb