very simple code - way 2 slow at times
Posted: Sun Oct 03, 2004 5:47 am
ok i have this code running
now this code is fine, i get no errors or nothing.
however, at times (mainly when i have not "used" the browser in +10 mins, then the parse time solely for this function can get upto 43 secs (usually only goes to around 17 when its going badly)
usually this parses at 0.09 - 0.22, i use microtime function to verify this and have it running in all code, whilst creating the site to view bottle necks and it is definitely down to this function.
So im wondering why this is the case?
I was thinking because it is searching a 50k item database, but i have other queries searching that database also that return super-fast.
Also i looked into MySQL caching and established that the resultset it always the same so it cant be that.
Does anyone have any ideas at all??
Thanks
Mal
Code: Select all
<?php
$time = time();
$query = "SELECT id, name, views, auction_start, auction_end FROM items WHERE views >= 1 AND auction_end < $time ORDER BY views DESC LIMIT 5";
$result = mysql_query($query) or die (mysql_error());
$num = mysql_num_rows($result);
if ($num >= 1)
{
while ($array = mysql_fetch_array($result))
{
print {$array['id']};
print {$array['name']};
print {$array['views']};
}
}
?>however, at times (mainly when i have not "used" the browser in +10 mins, then the parse time solely for this function can get upto 43 secs (usually only goes to around 17 when its going badly)
usually this parses at 0.09 - 0.22, i use microtime function to verify this and have it running in all code, whilst creating the site to view bottle necks and it is definitely down to this function.
So im wondering why this is the case?
I was thinking because it is searching a 50k item database, but i have other queries searching that database also that return super-fast.
Also i looked into MySQL caching and established that the resultset it always the same so it cant be that.
Does anyone have any ideas at all??
Thanks
Mal