Both routines would be improved by reducing or eliminating global variables, and passing subroutines all the parameters they need. It would help to go through the exercise of converting your script to run under strict.
The first version would be improved by preparing a statement handle once, using placeholders,
The improvement here is not only in performance, but also in the safety of the DBI quoting mechanism invoked by the placeholders.my $sth = $dbh->prepare( q(UPDATE url_table SET hits=? WHERE url=?)); while (my ($url, $hits) = each %urlhits_update) { $sth->execute($hits, $url); # ... }
You won't be able to LOAD FILE from an in-memory file you've constructed. That would require a) A db server which can do so, and b) shared memory between the server and your perl process. Neither is likely.
Is 0.26 seconds really too slow?
After Compline,
Zaxo
In reply to Re: speedy update routine
by Zaxo
in thread speedy update routine
by js1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |