Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
go ahead... be a heretic

Re: DBI execute_array

by samtregar (Abbot)
on Feb 11, 2009 at 16:53 UTC ( #743109=note: print w/ replies, xml ) Need Help??

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.


Comment on Re: DBI execute_array
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://743109]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2014-04-20 09:37 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (485 votes), past polls