Insert billions of data into mongodb

Hi @inokiyo welcome to the community!

I would say that the insert speed depends primarily on the hardware. Although you can create a highly parallel script to do the insertion, there’s only so many cores that process the work. A larger server with more processing power will definitely be able to do this faster.

If applicable, using an official tool such as mongoimport may be beneficial, since it was written with the best insert performance in mind (given the hardware).

the perfromance of mongodb is slow when it counting millions of documents, is it normal?

If it still does a heavy insertion work when you execute this command, then you’re asking the server to do even more work, so yes it will be slow :slight_smile:

If you don’t need high precision, you might be able to use db.collection.estimatedDocumentCount() that returns the number using the collection’s metadata instead, which will be less precise but would not impose extra work on the server.

Best regards
Kevin

1 Like