Hey there,

Does anyone know why a query would take a very long time (>15 minutes) from
my CGI script, yet takes less than a second if I cut-and-paste into my
console?

The query itself amounts to this:
SELECT ((a.PRECIP>(0.00*AVG(b.PRECIP/100)))), a.DATE
FROM clim_data AS a
LEFT JOIN clim_data as b ON a.station=b.station and b.DATE=a.DATE - INTERVAL
30 DAY
WHERE a.station IN ('426409',
    ... long list of ID codes, about 500 of them ...
    'WYTOR') AND a.DATE>=20010101 AND a.DATE<=20010102
GROUP BY DAYOFYEAR(a.DATE), a.station
...
1174 rows in set (0.53 sec)

My code is pretty simple:
-------------
    $Result = RunQuery("$q1$q2$q3");
   my %attribs;
   while(($value, $date)=$Result->fetchrow_array)
   {
    $attribs{$date} += $value;
   }
   $Result->finish;

--------------

sub RunQuery {
 my ($query) = @_;
 my $query_submittion = $database->prepare($query);
 Debug(5, $query);
 $query_submittion->execute() or Debug(1, $database->errstr, "Query Error on
\"$query\"");
 return $query_submittion;
}

--------------

But the server eventually will time-out.  A query involving only one date
requires next to no time if I type it in manually, but 10 minutes from my
webpage.

Are there any variables I might have set wrong that would cause this to
happen?  The MySQL server is on the same machine as the Apache one, and
there are a large number of rows being returned from this query.  My first
thought is that the number of station ids being sent is what is taking so
long.

Any help is appreciated!

Thanks,
Nick Elliott


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to