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@xxxxxxxxx> 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 > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php