简体   繁体   English

SqlBulkCopy 仍然比 Dapper 快吗?

[英]Is SqlBulkCopy still faster than Dapper?

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:我找到了 Sam Saffron 的一篇关于使用Dapper进行批量插入的文章( 使用 dapper 将数据导入数据库的烦人插入问题),他在文章结尾处用了以下语句:

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.例如,如果您需要一种将大量内容插入 SQL 数据库的超快速方法,那么没有什么比 SqlBulkCopy 更好,您将需要一个自定义 API。

The article is over 4 years old.这篇文章已经超过 4 年了。

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 ).我最近偶然发现了Dapper Plus ,它声称能够在 2,000 毫秒内处理 1,000,000 行,根据我发现的许多旧性能文章(例如这篇 - Evaluating ORMs for batch data ),这似乎优于SqlBulkCopy

My Google-fu has unfortunately failed in finding more recent performance comparisons between these two bulk import methods.不幸的是,我的 Google-fu 未能找到这两种批量导入方法之间最近的性能比较。

Question: Is SqlBulkCopy still faster than Dapper.NET ?问题: SqlBulkCopy仍然比Dapper.NET快吗?

Disclaimer : I'm the owner of the project Dapper Plus免责声明:我是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.当有足够的实体可以保存时,Dapper Plus for SQL Server/Azure 在后台使用 SqlBulkCopy,否则它将使用 SQL 派生表。

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这篇文章是关于实体框架的,但如果你想了解更多信息,它与 Dapper 的策略相同:实体框架如何在 SQL Server 中批量插入

So, our library obviously does not outperform SqlBulkCopy, it's the same performance, but our library makes it easier to use.因此,我们的库显然没有优于 SqlBulkCopy,性能相同,但我们的库使其更易于使用。

The library also support:该库还支持:

  • BulkUpdate批量更新
  • BulkDelete批量删除
  • BulkMerge批量合并

using SqlBulkCopy and Temporary Table tricks.使用 SqlBulkCopy 和临时表技巧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM