MySQL’s Slow Query Log

Zach suggested it last week, but it’s only now that I’ve gotten around to setting up MySQL’s slow query log.

It’s easy enough, you’ve just got to put a couple lines like this in your my.cnf (which is in /etc on my server):

log-slow-queries = /var/log/mysql/mysql-slow.log
long_query_time = 10

This should get most people running, but this story in Database Journal offers a few more details. Potentially more useful is this guide to query and index optimization (though it’s probably a little out of date).

mysql, mysql optimization, performance optimization, query optimization, slow query log, slow queries, high performance mysql

One thought on “MySQL’s Slow Query Log

  1. FYI I could only get this to work for me if I put those lines specifically in the [mysqld] section of the /etc/my.cnf file and also created the directory and touched the file making sure owner and group of the slow log file were mysql/mysql

Comments are closed.