gpt4 book ai didi

sql-server-2008 - BULK INSERT 还是导入和导出数据向导?

转载 作者:行者123 更新时间:2023-12-02 09:36:53 25 4
gpt4 key购买 nike

我每周有一个大型 CSV 文件(范围从 500MB 到 1GB,超过 250 万行)要加载到 SQL Server 2008 R2 数据库中。

我能够使用 BULK INSERT 命令或导入和导出数据向导来加载数据。就我的数据集而言,它们之间的加载时间跨度没有观察到差异。

就性能而言,您推荐的方法是什么。效率和日后维护有关?

提前致谢!

干杯,亚历克斯


我最终使用 SQL Server 导入和导出数据向导并将其保存到 SSIS 包中。然后我使用 Business Intelligence Development Studio 编辑保存的包并将其重新导入回 SQL Server。它运行良好,只需 2 分钟即可将所有 9 个 CSV 文件从 10MB 到 600MB 加载到 SQL Server 数据库。

最佳答案

MSDN 论坛:

When a SSIS developer opted for using the "Fast Load" option along with the "Table lock" on the OLEDB target, or used the SQL Server Destination, then he/she has effectively used the very BULK INSERT, so this is a moot point to debate what is faster.

Bulk insert on its own has tricks, in SQL Server contest more can be done to make it faster a row process, namely making it minimally or not logging at all. Now disabling constraints is another thing the bcp takes care of, not SSIS (unless instructed), and this what MSFT can decide to change in SSIS, but where the SSIS shines is in using an algorithm figuring out what are the best parameters for a given machine/system to use (e.g. the buffer size, etc).

So in most applications the SSIS is faster right away and even more faster with proper tweaking.

In real life many factors bring different impacts to the benchmarking, but at this stage I am inclined to state there is no real measurable difference.

Microsoft 发布了关于比较不同加载策略以实现高性能和在批量加载方法之间进行选择的非常有用的指南 - The Data Loading Performance Guide

也可以看看下面的文章。

关于sql-server-2008 - BULK INSERT 还是导入和导出数据向导?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24794656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com