I also noticed that the slow-down only happened if the application ran on a different machine than the sql server. For example I was browsing from my machine ( 192.168.0 .10) to the Apache server on the same machine (localhost) which in turn connected to a MySQL database on another machine in the same LAN (192.168.0.99). When I connected to Apache on 192.168.0 .99 and it used localhost to connect to mysql everything was smooth.
The solution - as I found out after several hours of Google-ing - is a little configuration option in mysql's my.cnf (or my.ini as your case may be):
skip-name-resolveThis should go in your [mysqld] section, so I just added mine at the bottom. Here's the what the whole section looks like:
[mysqld] user = mysql socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp skip-external-locking skip-name-resolveWhile I am not exactly clear on what is causing the slowdown, I believe it is due to the MySQL server attempting to resolve a host name for the server connecting to it if the connection comes through the network and not a local socket. As such it wastes some time attempting to resolve 192.168.0.10 which would fail.
No comments:
Post a Comment