Re: Code optimization
| From: | kranthi | Date: | Fri, 07 Aug 2009 06:13:54 +0000 |
| Subject: | Re: Code optimization | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46425@lists.php.net to get a copy of this message | ||
you can avoid using mysql_connect and mysql_close for every query
(they are the most costliest functions in your application)
you should not use mysql_result for this application
http://in2.php.net/function.mysql-result
try using mysql_fetch_assoc instead.
finally, use a good profiler, like xdebug to find the bottlenecks in
your application.
Kranthi.
On Fri, Aug 7, 2009 at 06:00, Chris<dmagick@gmail.com> wrote:
> Ron Piggott wrote:
>>
>> Is there a way to optimize this with better mySQL query?
>
> Step 1 - work out which bit is slow.
>
> $start_time = time();
> mysql_query (....)
>
> echo "That took " . (time() - $start_time) . " seconds<br/>\n";
>
>
> I'd guess the first one is slow because of the order by random()
>
> but that's just a guess.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>