Chris
Chris

Reputation: 3043

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. I am using Perl DBI to load the file using insert statements into a SQL Server. It is not very performant, and I was wondering if there are better/faster ways of loading from DBI into SQL Server.

Upvotes: 0

Views: 809

Answers (3)

Sven Eppler
Sven Eppler

Reputation: 1706

Another way to speed things up (if not already done) is to use prepared statements and bind-values.

Upvotes: 1

Dave Sherohman
Dave Sherohman

Reputation: 46245

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. This way, the indexes only have to be rebuilt once instead of rebuilding them after each INSERT/UPDATE statement runs.

(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.)

Upvotes: 1

mscha
mscha

Reputation: 6840

You should probably use the BULK INSERT statement. No reason you couldn't run that from DBI.

Upvotes: 4

Related Questions