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?
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.