Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my scenario I'm trying to debug:

I'm profiling MySQL queries using PHP's microtime() function, to determine how long each query takes. I have tested it on one domain, and comparing average query times. The databases on the local and remote server are identical.

When the site uses its local database server, the query times are all in the range of 0.0002-0.0004 secs as expected. The average query times when using the remote database are 0.0695 secs. Ping time from the domain's server to the remote DB's server are on average 0.0068 secs (68ms). That would put round-trip latency around 0.0136 sec per query. Wouldn't this mean that each query on the remote server should only take around 0.014 secs on average? We are averaging around 5x slower. Keep in mind these are very simple queries with tiny result sets. Skip name resolve is turned ON in my.cnf, and I am using the remote server's IP address for connection.

What other factors could be at play here and what should I look into?
Am I right to expect faster query times than what I am getting?

share|improve this question
Are you the only user of the database on the remote server? If not, try seeing how busy it is (show processlist). If you've got shell access, check the load averages via top, too, to see what else is going on while you're running your queries. – Mark Johnson Jan 3 '12 at 3:39
Thanks for the suggestion. The remote db server is a dedicated server with no other users and no other scripts running on it. Very little activity on a high powered server. – thedocta Jan 3 '12 at 6:19
What version of MySQL are you using? Are you connecting via a unix domain socket or a TCP socket to the local database? Try 'mysql --protocol=TCP', that should force TCP. See if that changes your timings. – Mark Johnson Jan 3 '12 at 16:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.