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


in reply to Re: DBI: How to update 150K records efficiently
in thread DBI: How to update 150K records efficiently

Thanks all for the helpful replies. :-)I've adjusted my code to:

my $sql = qq[ UPDATE `myTable` SET `va` = ?, `vb` = ? WHERE `vc` = ? ]; while (my $record = <$input>) { chomp $record; my ($val1, $val2, $val3) = (split(/\|/,$record))[1,3,5]; $db->query($sql, $val1, $val2, $val3); }

My question is: can we get the same 'prepare' effects as moritz mentioned in his post, since 'prepare' is done before the while loop..:)

BTW. thank you for your module, I've used it in most of my applications.

Best,
lihao

Replies are listed 'Best First'.
Re^3: DBI: How to update 150K records efficiently
by Juerd (Abbot) on Mar 31, 2008 at 15:22 UTC

    My question is: can we get the same 'prepare' effects as moritz mentioned in his post, since 'prepare' is done before the while loop..:)

    That is done automatically. DBIx::Simple recognises that the query is the same each time, and re-uses the old statement handle that represents the already compiled query.

    Juerd # { site => 'juerd.nl', do_not_use => 'spamtrap', perl6_server => 'feather' }