in reply to Efficiency on Code

Well... that code can be faster by doing:
for (1 .. $sth->do("COUNT SOMETHING")) { cleaner($TOTALLCLAIM); }
Because your not actually setting $TOTALLCLAIM anywhere in the loop! Are you using strict?

Anyway, assuming that 'ACCOUNT#' is an actual result column, you meant $TOALL instead of $TOTALLCLAIM, and you can write your SQL query so you only get that column from the DB (if you haven't done so already that will probably get you the biggest performance increase) - asking for an array will probably be slightly faster:

while (my ($accountno) = sth->fetchrow_array) { push @array_claim,$accountno; }

Usually you can gain the most performance in database related programs by carefully analyzing and (re)writing your queries and datamodel, though.

Replies are listed 'Best First'.
Re^2: Efficiency on Code
by dragonchild (Archbishop) on Jan 06, 2005 at 19:12 UTC
    Usually you can gain the most performance in database related programs by carefully analyzing and (re)writing your queries and datamodel, though.

    I would like to echo this. I once came onto a project and took reports that were running in 240s and by redoing the schema and the SQL, had those reports running in under 10s. That's an 24x speedup without changing a single part of the Perl code.

    I later improved the Perl code and took the reports to under 3s, but that's only a 3x speedup. That means that dealing with the database had 8x the impact as dealing with the Perl.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re^2: Efficiency on Code
by Anonymous Monk on Jan 06, 2005 at 19:15 UTC
    Where in your code I am looking for the colunm "ACCOUNT#" in the database?