Is SqlBulkCopy still faster than Dapper?

c# dapper performance sqlbulkcopy

Question

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?

Accepted Answer

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.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why