Apr 28, 2010

If connections from remote clients to MySQL are slow

MySQL attempts name resolving on remote connection and that can adversely impact performance.

I had a case where a client app written in Visual Basic, connecting via ODBC to a MySQL server running on Linux. It was abnormally slow. The VB app aquired a fresh connection upon every query and each query then took exactly 10 seconds to complete.
This smelled like a timeout scenario to me so I suspected a DNS lookup was taking place.

Adding the following config option to my.cnf solved the problem:
skip-name-resolve
It prevents MySQL from doing a DNS lookup of the remote clients IP adress.
Note that by using this option you can only use IP adresses (or "localhost") in the MySQL grants table.

More info at the MySQL site here:
http://dev.mysql.com/doc/refman/5.0/en/dns.html