Enabling MySQL slow query log or without indexes

In a production environment, it is recommended enabled the slow query log for analyzing occasionally.

Activation is performed in the parameter file used (usually my.cnf) adding within the section

[mysqld]:

Source   
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 10
log-queries-not-using-indexes

Enable the slow query log and will be written in the log (log_slow_queries parameter) that take longer than 10 seconds (long_query_time parameter) and also queries that are not using indexes (parameter log-queries-not-using-indexes).

Caution that the log file must be created before, although I have noticed that depends on the operating system and the version of MySQL.

It is possible that in this log queries that use indexes appear. What happens is that here also appear queries that perform a full scan of an index.

I leave a link to the documentation:

https://dev.mysql.com/doc/refman/5.5/en/slow-query-log.html

Leave a Reply