Source Code

Mysql Response too slow accessed from website

  • Subscriber
  • Jun 20' 14
  • MySQL
  • 245
  • 139
  • United States

Is your MySQL really slow without actually being too busy?
Does your scripts take very long time to connect to the database?
Do you have lots of RAM, strong CPU, just a little traffic and despite that a very long database response time?
Are you seeing connections with “unauthenticated user” while running show processlist in MySQL console?


if you show the proccess list on mysql server by typing 

show processlist;

screen will shown 

2047 | unauthenticated user | localhost | myDB    | Connect   |   81 |       | NULL   


If you answered yes to any of the above questions your MySQL might have a problem with resolving connection’s host name.
When attempt is made for a new connection, MySQL tries to resolve the host name for that request. It takes the IP address and resolves it to a host name (using gethostbyaddr()). It then takes that host name and resolves it backs to the IP address (using gethostbyname()) and compares to ensure it is the original IP address.
This might considerably increase connection time and slow down your whole application or produce show processlist result as above. You can easily solve this problem by disabling DNS host name lookups. In order to do this you need to run your mysqld with –skip-name-resolve option or add it to your my.cnf file like that:



After that running show processlist will result in “Host” column displaying only IP addresses instead of host names and the connection speed should be much faster.

Just keep in mind that also you have to change allowed hosts for your database users to proper IP addresses.


  • Tags : mysql, resolve, slow, database
comments powered by Disqus

Related Code

Dumping MySQL Database Using Command

Source Code - PQM - Pingi Query Manager

DNS Resolver

Create DB file at runtime

Get Database Path With Alias

Get database path with its alias