Why are insertMany() calls equivalent to calls to bulkWrite() in java-sync-driver 4.11.1

I’m going through the API reference for Mongocollection from the Java sync driver 4.11.1. I’ve noticed that in the definition of all the insertMany method variations, there’s this line

A call to this method is equivalent to a call to the bulkWrite method

So I wanted to understand why this is so? A googled a bit and the surface level answer seems to be that’s it’s more efficient. I wanted to understand a bit more in detail why bulkwrite() is being used here.

Thanks.

Link to API ref- MongoCollection (driver-sync 4.11.1 API)

If bulkWrite function supports all the semantics of “insertMany” with all insert options, then why not?

Nobody wants to write duplicated code.

Unless insertMany has some special things and/or can be implemented in a more performant way.

1 Like