MongoDB bulk inserts with the C++ driver

Posted on 27 Nov 2010 by Nathan Ehresman

Do you have a massive number of records you need to dump into MongoDB in a hurry? Try out the bulk
insert capabilities of the C++ driver. Depending on the documents I routinely get an insert rate of 50,000 records/sec, sometimes even up over 100,000/sec.

The trick is to use a vector of BSON objects and call insert once. Here’s a simple example application.

Tebros Systems is a software incubator that creates
custom and hosted software solutions.

We are eager to solve difficult problems, create usable web apps, and make
your idea become reality. We have a wide range of experience from web
development to database optimization to usability analysis and more. Contact
us with your idea. We’ll walk you through a feasibility assessment and help
your project come to life.