Re: Re: Performance problems?
| From: | Leif K-Brooks | Date: | Sat, 02 Nov 2002 07:04:59 +0000 |
| Subject: | Re: Re: Performance problems? | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22909@lists.php.net to get a copy of this message | ||
Aha - thanks. The problem is, I also need to retrieve other data asscociated with it. I'll alter the table to order by id, but is there anything long-term I can do?
Manuel Lemos wrote:
Hello, On 11/02/2002 03:21 AM, Leif K-Brooks wrote:-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.I've been optimizing scripts in an attempt to speed my friend's site up, and I believe I've found the source of the performance problems. When I comment the following page load time changes from around 6 seconds to less than .5 of a second. if($loggedin){The order by clause is the killer. It forces the server to rebuild the whole table in memory just to returned the results sorted. If you just want the highest id, use MAX(id) .$events = mysql_query("select * from events where whofor='{$userinfo['id']}' order by id desc limit 1"); if(mysql_num_rows($events) == 1){ $events = mysql_fetch_array($events); print <<< END <p align="center"><a href="{$basepath}doevent.php?id={$events['id']}">{$events['message']}</a></p> END; }} This code checks for events (new mail, etc.) that the user may have and dispays them. Any idea on what makes it perform this badly?