简体   繁体   English

Azure SQL Server中的批量插入或BCP

[英]Bulk Insert or BCP in Azure SQL Server

I am trying to load data into Azure SQL server using BULK Insert and BCP. 我正在尝试使用BULK插入和BCP将数据加载到Azure SQL服务器中。 I am able to load data into my table without any issues, but load performance is the issue in my case. 我能够将数据加载到表中而没有任何问题,但是加载性能是我的问题。 BCP is faster in most cases then BULK Insert. 在大多数情况下,BCP比批量插入要快。

BCP BCP

Loading data from UNIX to database 将数据从UNIX加载到数据库

BULK INSERT 批量插入

Loading data into Azure SQL Server via BLOB storage 通过BLOB存储将数据加载到Azure SQL Server中

I would like to know to how to improve the BULK Insert performance other than adding TABLOCK and drop/recreate index. 除了添加TABLOCK和删除/重新创建索引外,我想了解如何提高BULK插入性能。 Drop and recreate index is not possible due to incremental loads. 由于负载增加,无法删除和重新创建索引。

What are all the parameters to tweak for improved BULK INSERT performance? 需要调整哪些参数以提高BULK INSERT性能?

Batching calls to a remote service is a well-known strategy for increasing performance and scalability. 批量调用远程服务是提高性能和可伸缩性的众所周知的策略。 There are fixed processing costs to any interactions with a remote service, such as serialization, network transfer, and deserialization. 与远程服务的任何交互(例如序列化,网络传输和反序列化)都具有固定的处理成本。 Packaging many separate transactions into a single batch minimizes these costs. 将许多单独的交易打包为一个批次可以最大程度地降低这些成本。

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-use-batching-to-improve-performance#why-is-batching-important-for-sql-database https://docs.microsoft.com/en-us/azure/sql-database/sql-database-use-batching-to-improve-performance#why-is-batching-important-for-sql-database

  1. BCP is an utility program: bcp.exe. BCP是一个实用程序:bcp.exe。
  2. BULK INSERT is a Transact-SQL statement. 批量插入是Transact-SQL语句。

bcp.exe uses BULK INSERT to do its job. bcp.exe使用BULK INSERT来完成其工作。

BCP and BULK INSERT are actually different implementations. BCP和BULK INSERT实际上是不同的实现。 Logically they are equivalent, or at least supposed to be. 从逻辑上讲,它们是等效的,或者至少应该是等效的。 BCP has less parsing efforts and cost than BULK INSERT. 与批量插入相比,BCP的解析工作和成本更少。 Both are almost same and give almost same performance. 两者几乎相同,并且性能几乎相同。

If you want test or compare them performance, they must in the same system and do the same operation: loading data file into Azure SQL Server via BLOB storage or load data file into Azure SQL server. 如果要测试或比较它们的性能,它们必须在同一系统中并执行相同的操作:通过BLOB存储将数据文件加载到Azure SQL Server中或将数据文件加载到Azure SQL Server中。 Otherwise, you may get the incorrect result. 否则,您可能会得到错误的结果。

Azure SQL Server doesn't specifically how to improve BULK INSERT performance. Azure SQL Server并没有专门介绍如何提高“批量插入”性能。 But I think if we follow the document BULK INSERT (Transact-SQL) does, there may not have performance issues. 但是我认为,如果按照文档BULK INSERT(Transact-SQL)进行操作,则可能不会出现性能问题。

Hope this helps. 希望这可以帮助。

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

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