Re: [PHP-DB] Code optimization

2009-08-07 Thread Phpster
On Aug 6, 2009, at 7:52 PM, "Ron Piggott" wrote: Is there a way to optimize this with better mySQL query? # Select today's Bible verse mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM verse_of_the_da

Re: [PHP-DB] Code optimization

2009-08-07 Thread chris smith
On Fri, Aug 7, 2009 at 5:10 PM, kranthi wrote: >>> You're assuming that. It could be the queries being run are the costliest. > > It has got nothing to do with the cost of query. bare mysql_connect() > is very costly. I'm not arguing with that, I'm saying that the cost of the mysql_connect could b

Re: [PHP-DB] Code optimization

2009-08-07 Thread kranthi
>> You're assuming that. It could be the queries being run are the costliest. It has got nothing to do with the cost of query. bare mysql_connect() is very costly. compare \n"; $time = microtime(true); mysql_connect('localhost', 'user', 'pass'); mysql_close(); echo (microtime(true) - $time); wit

Re: [PHP-DB] Code optimization

2009-08-06 Thread Chris
kranthi wrote: you can avoid using mysql_connect and mysql_close for every query (they are the most costliest functions in your application) You're assuming that. It could be the queries being run are the costliest. you should not use mysql_result for this application http://in2.php.net/funct

Re: [PHP-DB] Code optimization

2009-08-06 Thread kranthi
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 xdebu

Re: [PHP-DB] Code optimization

2009-08-06 Thread Chris
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\n"; I'd guess the first one is slow because of the order by random() but that's j

[PHP-DB] Code optimization

2009-08-06 Thread Ron Piggott
Is there a way to optimize this with better mySQL query? # Select today's Bible verse mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM verse_of_the_day_Bible_verses WHERE `assigned_date` = '-00-00' AND se