I've created a simple PHP test page which connects to a MySQL database, selects one int value, and then frees the result. The page takes 5 seconds or more to load. I've seen a lot of posts about this or similar issues but not of the resolutions have worked. Here is the output I'm getting:
mysql_connect took 4.8948628902435 seconds
mysql_select_db 0.00073790550231934 seconds
mysql_query took 0.0013959407806396 seconds
mysql_free_result took 2.0980834960938E-5 seconds
As you can see, the connection takes far too long and everything else is fast.
FYI - I don't do PHP so it's okay to treat me like a baby when suggesting fixes.
<?php
$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
mysql_connect("the_ip||the_hostname", "the_username", "the_password");
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo '<h2> mysql_connect took ' .$totaltime. ' seconds</h2>';
?>
Trace route is instantaneous: By the way, the application in question is MantisBT as well as Wordpress.
1 2 ms <1 ms <1 ms 1.2.3.4
2 <1 ms <1 ms <1 ms MYSQL5 [5.6.7.8]
Another thing to look at is "mysql_connect" which might show you that PHP is having a hard time resolving (finding) the mysql host. Are you using a IP address, localhost, or hostname? (when connecting to the database in php) If it's a hostname try and add the IP to c:\windows\system32\drivers\etc\host
if that doesn't work. If all your "The Facts" are correct then you might have a issue with your php script. Can you post it so I can see what you are running? Also post the mysql table info like "Indexes" etc.
:)
I had a similar problem, PHP was accessing MySQL with a simple select statement but taking for ages to display.
With help from another forum, the guy suggested that I make a new website and give it a different port than 80, so I did, In IIS manager, under sites, add new site and point it to the virtual DIR, entered the IP address of the server 192.168.2.2 and gave it port 82.
Opened port 82 in firewall and from a networked XP machine entered into the browser 192.168.2.2:82 and it was lightening. Worked first time.
Also, in the IIS manager for the new website, In Output Cacheing, Uncheck Use-mode cache, and it lets the pages run and enter data using the php pages.
A bit late with the reply, but thought I would share it any ways.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With