I haven’t been generous enough to spend money on higher RAM for my blogs. I started to notice slow downs in the blog recent, particularly caused by a particular plugin that does related posts. I found out by checking on slow queries log. Here’s how to get MySQL to log slow queries:
If you are using Ubuntu of Debian-based operating systems, it’s found in /etc/mysql/my.cnf. You may need to use
[code lang=”bash”]sudo nano /etc/mysql/my.cnf[/code]
Press CTRL + W, that’s search in nano. Find “slow” for the section for logging slow queries.
[code lang=”bash”]# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
I uncommented “log_slow_queries” and “long_query_time”. I put long_query_time to 8. That requires a bit of experimentation. It depends on your environment.
I run the following command to check the slow queries:
[code lang=”bash”]sudo cat /var/log/mysql/mysql-slow.log[/code]
After you change the configuration in my.cnf, you need to restart. You can do so using:
[code lang=”bash”]sudo /etc/init.d/mysql restart[/code]
Hope it helps.