http://www.perlmonks.org?node_id=279606

jjhorner has asked for the wisdom of the Perl Monks concerning the following question:

All,

I've got large amounts of data that I need to put into a database (a few 10M records).

My question is this:

If I connect to the database, cycle through each line and execute the SQL to add the line to the database, it takes a while to insert into the database across Unix sockets. What ways can I speed up the insertion so that I can batch most of it? It is conceivable that I can do one mass SQL string with multiple inserts at once? Will I gain any speed that way? Example:

my $SQL = "blah\;"; $SQL .= "blah\;"; $SQL .= "blah\;";

Or should I do it normally:

my $SQL = "blah"; <insert DBI code to execute here>
Any advice will be helpful...
J. J. Horner 
CISSP,CCNA,CHSS,CHP,blah,blah,blah