http://qs321.pair.com?node_id=743109


in reply to DBI execute_array

What database are you using? If it's MySQL I'm pretty sure a multi-value insert will be faster. For example, you could insert in blocks of 100:

my $sql = "INSERT INTO temp_selectedTitles values ". join(", ", "(?) +" x 100); my $sth = $dbh->prepare($sql); for (my $i = 0; $i <= $#books; $i+=100) { $sth->execute(@books[$i..$i+99]); }

Of course if you don't have an exact number of blocks then you have to clean up what's left with another statement, either one at a time or custom fitted. I use this technique all the time and it always beats going row by row.

I think execute_array() is mostly abandoned at this point - I can't remember the last time I saw it used outside the DBI docs.

-sam