为什么BCP这么快?
因此,BCP 将数据插入 SQL Server DB 的速度非常非常快。是什么让它如此之快?
So BCP for inserting data into a SQL Server DB is very very fast. What is is doing that makes it so fast?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 SQL Server 中,BCP 输入的记录方式与传统的插入语句非常不同。 SQL 决定如何处理事情取决于许多因素,有些是大多数开发人员从未考虑过的,例如数据库设置使用哪种恢复模型。
bcp 使用与 BULK INSERT 和 SqlBulkCopy 类相同的工具。
更多详情请点击此处
http://msdn.microsoft.com/en-us/library/ms188365.aspx
底线是,这些批量操作比正常操作记录更少的数据,并且能够指示 SQL Server 忽略其对传入数据的传统检查和平衡。所有这些因素共同作用,使其成为现实。 快点。
In SQL Server, BCP input is logged very differently than traditional insert statements. How SQL decides to handle things depends on a number of factors and some are things most developers never even consider like what recovery model the database is set to use.
bcp uses the same facility as BULK INSERT and the SqlBulkCopy classes.
More details here
http://msdn.microsoft.com/en-us/library/ms188365.aspx
The bottom line is this, these bulk operations log less data than normal operations and have the ability to instruct SQL Server to ignore its traditional checks and balances on the data coming in. All those things together serve to make it faster.
它作弊。
它对内部结构有深入的了解,并且能够将您的输入数据更直接地映射到这些内部结构。它可以跳过其他重量级操作(如解析、优化、事务、日志记录、延迟索引、隔离)。它可以做出适用于每一行数据的假设,而普通的插入 SQL 语句无法做到这一点。
基本上,它能够跳过使数据库成为数据库的大部分功能,然后在最后自行清理。
It cheats.
It has intimate knowledge of the internals and is able to map your input data more directly to those internals. It can skip other heavyweight operations (like parsing, optimization, transactions, logging, deferring indexes, isolation). It can make assumptions that apply to every row of data that a normal insert sql statement can not.
Basically, it's able to skip a bulk of the functionality that makes a database a database, and then clean up after itself en masse at the end.
我知道 bcp 和普通插入之间的主要区别是 bcp 不需要为每个单独的事务保留单独的事务日志条目。
The main difference I know between bcp and a normal insert is that bcp doesn't need to keep a separate transaction log entry for each individual transaction.
速度是因为他们使用 SQL Server Native Client ODBC 驱动程序的 BCP API。根据微软的说法:
http://technet.microsoft.com/en-us/library /aa337544.aspx
批量复制功能参考:
http://technet .microsoft.com/en-us/library/ms130922.aspx
The speed is because they use of BCP API of the SQL Server Native Client ODBC driver. According to Microsoft:
http://technet.microsoft.com/en-us/library/aa337544.aspx
Bulk Copy Functions reference:
http://technet.microsoft.com/en-us/library/ms130922.aspx