MongoDB InsertMany vs BulkWrite

Alisettar Huseynli picture Alisettar Huseynli · Mar 2, 2016 · Viewed 13k times · Source

I am using MongoDB for keeping log data. And my goal is zero dropped log record. Now i am using "InsertManyAsync" for writing multiple log data. But in MongoDB there is also method like "BulkWriteAsync". What is the difference in performance between InsertMany and BulkWrite? In local writing and writing over network?

Answer

Adrian Lopez picture Adrian Lopez · Mar 3, 2016

Ok that's two questions:

InsertMany vs BulkWrite

Using BulkWrite you can do many operations in a single connection to mongoDB. Internally, InsertMany uses BulkWrite, so there's no difference, it's just for convenience.

This question was already solved.

Sync vs Async

When you perform a sync operation, your aplication will wait for MongoDB to finalize the work. With a async operation you can perform many operations at the same time. Server, and client side.

This was already solved too.