Search code examples
mongodbgomgomongo-go

Which library is More Efficient "gopkg.in/mgo.v2" or "go.mongodb.org/mongo-driver/mongo"


I am using Golang as backed language with mongodb database and also new to this language.I have used both libraries "gopkg.in/mgo.v2" and "go.mongodb.org/mongo-driver/mongo" to perform all CRUD oprations. My Question is which one is more efficient to use according to all parameters like lightweight,performance,execution time etc.?


Solution

  • I don't think it should be a question of efficiency. mgo has long gone unmaintained and does not support new features of new versions of MongoDB (such as ACID transactions), while the other is the official driver with regular updates. Use the official driver.

    Both drivers execute basic operations nearly at same speed. Run benchmarks if you need exact figures, but again, there are more to consider than just "raw" speed.