|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
|
The bug was updated successfully.
[2012-11-15 09:09 UTC] admin at wudimei dot com
Description:
------------
php5.4.8 connecting to mysql is slower then php5.2.8
i use php5.4.8 to connect the mysql,it's slow!it take about 1.0138568878174 seconds.
then i switch to php5.2.6 ,it only take 0.00234985351562 seconds.
please improve it
thank you!
yang qingrong
Test script:
---------------
<?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();
?>
php5.4.8 output:
Array ( [Tables_in_yqr] => account_book ) Array ( [Tables_in_yqr] => customer ) Array ( [Tables_in_yqr] => domain ) Array ( [Tables_in_yqr] => friends ) Array ( [Tables_in_yqr] => hourly_work ) Array ( [Tables_in_yqr] => hourly_work_project ) Array ( [Tables_in_yqr] => notepad ) Array ( [Tables_in_yqr] => notepad_ctg ) Array ( [Tables_in_yqr] => schedule ) 1.0138568878174 seconds
php 5.2.6 output
Array ( [Tables_in_yqr] => account_book ) Array ( [Tables_in_yqr] => customer ) Array ( [Tables_in_yqr] => domain ) Array ( [Tables_in_yqr] => friends ) Array ( [Tables_in_yqr] => hourly_work ) Array ( [Tables_in_yqr] => hourly_work_project ) Array ( [Tables_in_yqr] => notepad ) Array ( [Tables_in_yqr] => notepad_ctg ) Array ( [Tables_in_yqr] => schedule ) 0.00234985351562 seconds
Patchesissue-above (last revision 2012-11-15 09:10 UTC by admin at wudimei dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 23:00:02 2025 UTC |
i edited the code like this: <?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 "<br /><b>connect to mysql take ". (microtime(true ) - $a); echo " seconds</b>"; phpinfo(); ?> to see the result,copy the url below and paste it to the address bar of browser: http://www.wudimei.com/data/YangQingrong/php5.2.6.jpg http://www.wudimei.com/data/YangQingrong/php5.4.8.jpg<?php $a = microtime( true ); $conn = mysql_connect("127.0.0.1","root","123456"); mysql_select_db("yqr"); $q = mysql_query("show tables"); while( $r = mysql_fetch_assoc( $q )) { print_r( $r ); } echo "<br /><b>connect to mysql take ". (microtime(true ) - $a); echo " seconds</b>"; phpinfo(); ?> connect to mysql take 0.0034029483795166 seconds thanks rasmus@php.net very much,this issue solved! thank you again! best regards yangqingrong