Gorm Bulk Insert is a library to implement bulk insert using gorm. Execute bulk insert just by passing a slice of struct, as if you were using a gorm regularly.
When saving a large number of records in database, inserting at once - instead of inserting one by one - leads to significant performance improvement. This is widely known as bulk insert.
Gorm is one of the most popular ORM and contains very developer-friendly features, but bulk insert is not provided.
This library is aimed to solve the bulk insert problem.
$ go get github.com/t-tiger/gorm-bulk-insert
This library depends on gorm, following command is also necessary unless you’ve installed gorm.
$ go get github.com/jinzhu/gorm
Dependency: It depends on 1.9.3 or later version of Gorm. If you’ve installed earlier version, please update gorm.
gormbulk.BulkInsert(db, sliceValue, 3000)
Third argument specifies the maximum number of records to bulk insert at once. This is because inserting a large number of records and embedding variable at once will exceed the limit of prepared statement.
Depending on the number of variables included, 2000 to 3000 is recommended.