Re: Code optimization
| From: | kranthi | Date: | Fri, 07 Aug 2009 07:10:43 +0000 |
| Subject: | Re: Code optimization | ||
| References: | 1 2 3 4 5 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46427@lists.php.net to get a copy of this message | ||
>> 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
<?php
$time = microtime(true);
mysql_connect('localhost', 'user', 'pass');
//mysql_close();
echo (microtime(true) - $time) . "<br>\n";
$time = microtime(true);
mysql_connect('localhost', 'user', 'pass');
mysql_close();
echo (microtime(true) - $time);
with
<?php
$time = microtime(true);
mysql_connect('localhost', 'user', 'pass');
mysql_close();
echo (microtime(true) - $time) . "<br>\n";
$time = microtime(true);
mysql_connect('localhost', 'user', 'pass');
mysql_close();
echo (microtime(true) - $time);
to see the difference.