6

I found an article by Sam Saffron on bulk inserting with Dapper (That annoying insert problem getting data into the db using dapper) where he ends the article with the statement:

For example, if you need an ultra fast way to insert lots of stuff into a SQL DB, nothing is going to beat SqlBulkCopy and you are going to need a custom API for that.

The article is over 4 years old.

I recently have stumbled across Dapper Plus which claims to be able to do 1,000,000 rows in 2,000ms which would appear to outperform SqlBulkCopy based on many old performance articles I found (such as this one - Evaluating ORMs for batch data).

My Google-fu has unfortunately failed in finding more recent performance comparisons between these two bulk import methods.

Question: Is SqlBulkCopy still faster than Dapper.NET?

Jonathan Magnan
  • 10,874
  • 2
  • 38
  • 60
toadflakz
  • 7,764
  • 1
  • 27
  • 40
  • 1
    It's not open source, but given the [Performance Tuning wiki](https://github.com/zzzprojects/Bulk-Operations/wiki/Performance-Tuning-Options) says you can customise the `SqlBulkCopyOptions`, I'd suggest its SQL Server implementation is a wrapper around `SqlBulkCopy`. – Charles Mager Sep 01 '16 at 10:33
  • I think you're looking at the wrong library though. They have a Standard ADO.NET library too. I might have linked the wrong thing. – toadflakz Sep 01 '16 at 10:54
  • I assume they're all based on the same thing, but [here's the Dapper Plus specific one](https://github.com/zzzprojects/Dapper-Plus/wiki/dapper-plus-mapper-sql-server). – Charles Mager Sep 01 '16 at 10:55
  • That uses the Dapper Plus - Mapper though not Dapper Plus - Actions, specifically https://github.com/zzzprojects/Dapper-Plus/wiki/dapper-plus-bulk-insert – toadflakz Sep 01 '16 at 10:57
  • Per [the introduction](https://github.com/zzzprojects/Dapper-Plus/wiki/dapper-plus-introduction), they seem rather intertwined: *Dapper Plus Mapper allow to map the conceptual model (Entity) with the storage model (Database) and configure options to perform Bulk Actions.*. – Charles Mager Sep 01 '16 at 10:59
  • I might have to dive into their code to verify what they used... – toadflakz Sep 01 '16 at 11:02

1 Answers1

7

Disclaimer: I'm the owner of the project Dapper Plus

Dapper Plus for SQL Server/Azure uses SqlBulkCopy under the hood when there are enough entities to save otherwise it will use a SQL derived table.

This article is about Entity Framework, but it's the same strategy for Dapper if you want more information: Entity Framework How to Bulk Insert in SQL Server

So, our library obviously does not outperform SqlBulkCopy, it's the same performance, but our library makes it easier to use.

The library also support:

  • BulkUpdate
  • BulkDelete
  • BulkMerge

using SqlBulkCopy and Temporary Table tricks.

Jonathan Magnan
  • 10,874
  • 2
  • 38
  • 60
  • 9
    Just to be sure developers are aware, Dapper Plus is not free/open source. The license fees start at $799/yr for one developer. A contractor built some software using Dapper Plus without being aware of this. Just know that if you install this, you will eventually need to pay that price. In my opinion it is very expensive for what it does. – brianc Nov 17 '20 at 22:17
  • 2
    Thanks for the heads up that was not AT ALL clear. – niico Mar 05 '21 at 09:25