How to check the performance of a plugin using mysql query log

Installing too many plugins can hurt wordpress blog performance as plugins may lead to more queries. One quick way to check the impact of a plugin on mysql server is to enable the query log on the server.

On linux this can be done by editing /etc/my.cnf (or /etc/mysql/my.cnf) on Linux server.  Here is the addition/change which is needed

log=/var/log/mysql_query.log
(or whatever log file name you want to use)

Restart the mysql server after this. You use this command on linux (centos):
sudo service mysqld restart

You can view the log file using
tail -f /var/log/mysql_query.log

This can be used for:

  1. To find out if a plugin is sending too many queries to mysql database. In case it is behaving badly, you may want to look for alternatives.
  2. It can also help understanding what all tables a plugin is reading and writing. This can used to debug and also to understand data storage structure of a plugin.

Make sure you don’t enable logs in production system permanently. Either you do it on a devel/sandbox setup of do it for a short duration.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments