简体   繁体   English

Perl DBI-加载到SQL Serverl

[英]Perl DBI - Loading into SQL Serverl

I have to load a text file into a database on a daily basis that is about 50MB in size. 我每天必须将一个文本文件加载到数据库中,该文件的大小约为50MB。 I am using Perl DBI to load the file using insert statements into a SQL Server. 我正在使用Perl DBI使用插入语句将文件加载到SQL Server中。 It is not very performant, and I was wondering if there are better/faster ways of loading from DBI into SQL Server. 它的性能不是很好,我想知道是否有更好/更快的方法从DBI加载到SQL Server。

You should probably use the BULK INSERT statement. 您可能应该使用BULK INSERT语句。 No reason you couldn't run that from DBI. 没有理由您无法从DBI运行它。

When doing large INSERT / UPDATE operations, it's generally useful to disable any indexes on the target table(s), make the changes, and re-enable the indexes. 在执行大型INSERT / UPDATE操作时,通常禁用目标表上的任何索引,进行更改并重新启用索引通常很有用。 This way, the indexes only have to be rebuilt once instead of rebuilding them after each INSERT / UPDATE statement runs. 这样,索引仅需重建一次,而不必在每个INSERT / UPDATE语句运行后重建索引。

(This can also be applied in a zero-downtime way by copying the original table to an unindexed temp table, doing your work on the temp table, adding indexes, dropping the original table, and renaming the temp table to replace it.) (通过将原始表复制到未索引的临时表,在临时表上进行工作,添加索引,删除原始表并重命名临时表来替换它,也可以以零停机时间的方式来应用。)

加快速度(如果尚未完成)的另一种方法是使用准备好的语句和绑定值

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

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