I use the same script to test two versions of php. The notes are in Windows 7.
<? Php
$ A = microtime (true );
$ Conn = mysql_connect ("localhost", "root", "123456 ");
Mysql_select_db ("yqr ");
$ Q = mysql_query ("show tables ");
While ($ r = mysql_fetch_assoc ($ q ))
{
// Print_r ($ r );
}
Echo microtime (true)-$ a; echo "seconds"; exit ();
?>
The output result of php5.4.8 is:
1.0138568878174 seconds
Php 5.2.6 outputs the following results:
0.00234985351562 seconds
It can be seen that php5.4.8 is much slower to access mysql than php5.2.6. When I started using php5.4.8, I thought it was mysql that slowed down, deleted logs, and improved mysql performance. It was still not necessarily faster, and the speed was more than 1 second. Later, after I switched to php5.2.6, the access speed suddenly dropped to about 0.002 seconds. It does not seem like a problem with mysql, but with mysql extension in php. If you upgrade php5.4.8 to php5.4.8, pay attention to it.
Husband to php.net asked the master, the URL is: https://bugs.php.net/bug.php? Id = 63525 & thanks = 2. The expert's answer is: the simple solution is to replace localhost with 127.0.0.1. I did it, and the speed was faster. He said that because Windows 7 uses localhost as ipv6 for parsing, and mysql does not listen at: 127.
Connect to mysql take 0.0034029483795166 seconds
$ Conn =Mysql_connect ("127.0.0.1", "root", "123456"); // note that 127.0.0.1 should not be written as localhost.
Address: http://wudimei.com/yangqingrong/blog/show/133