Skip to content
Lukáš Šefčík edited this page Mar 1, 2019 · 1 revision

Bulk operation performance

KORM support bulk operations BulkInsert and BulkUpdate. Thanks to this, it can handle a lot of data very quickly.

Microsoft SQL Server

Operation 1 000 Entities 5 000 Entities 10 000 Entities 20 000 Entities
Pure Ado.Net inserts 474 ms 2233 ms 3289 ms 6604 ms
BulkInsert with KORM 187 ms 284 ms 678 ms 721 ms
Pure Ado.Net update 350 ms 2878 ms 3354 ms 6011 ms
BulkUpdate with KORM 86 ms 542 ms 644 ms 991 ms

Microsoft Access

Operation 1 000 Entities 5 000 Entities 10 000 Entities 20 000 Entities
Pure Ado.Net inserts 854 ms 4 113 ms 8 241 ms 15 874 ms
BulkInsert with KORM 418 ms 480 ms 684 ms 1 105 ms
Pure Ado.Net update 1337 ms 6272 ms 12564 ms 25328 ms
BulkUpdate with KORM 355 ms 702 ms 1035 ms 1898 ms

This is not an official benchmark. The data contains 23 columns. It was tested on Intel Core i7 vPro, 16 GB RAM and SSD. But for comparison it is sufficient.

Example

BulkInsert

using (var database = new Database("connectionstring ...", "ado client name ..."))
{
    database
       .Query<Movie>()
       .AsDbSet()
       .BulkInsert(_data);
}

BulkUpdate

using (var database = new Database("connectionstring ...", "ado client name ..."))
{
    database
        .Query<Movie>()
        .AsDbSet()
        .BulkUpdate(_data);
}

If you do not need to use ORM and have the source data reader available, you can use the SqlServerBulkInsert / SqlServerBulkUpdate or MsAccessBulkInsert / MsAccessBulkUpdate classes to perform bulk operations.

For example:

using (var bulkInsert = new SqlServerBulkInsert("connection string"))
{
    bulkInsert.Insert(reader);
}

For more information see home page.

Clone this wiki locally