"Toddy Prawiraharjo" schreef:

Don't top-post. Don't quote text that is no longer relevant, especially
intros and signatures.

> [SQL-emulation in Perl]
> Any more way to process this beast any faster?
> Any good reading or reference about this? Just afraid, if this rolled
> to production level, the report for months activities will take
> minutes to make!
>
> <snipped>
>         $query = "SELECT src, sent, rcvd FROM no_name WHERE start_date
>> = '$fromdate' AND start_date <= '$todate';";
>         $sth = $dbh->prepare($query);
>         $sth -> execute() || &errorhere("SQL Error: $DBI::errstr");
>         #print "$query<br>";
>
>         my %src = ();
>         my ($totalsent, $totalrcvd);
>
>         while(@row = $sth->fetchrow_array){
>                 my $key = $row[0];
>                 $src{$key} += $row[2];
>                 $totalsent = $totalsent + $row[1];
>                 $totalrcvd = $totalrcvd + $row[2];
>         }
> </snipped>

You are doing things in Perl that you should do in SQL. Look for GROUP
BY and SUM.
Also check out DBI's prepare().

(Don't call your database "very big" unless some important process takes
more than 24 hours.)

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to