Thursday 10 November 2011

Mysql - Enable slow query logging

Enabling slow query logs is one of the recommended options to determine long running queries, lock timeout issues and non-indexed queries.

Uncomment the below lines in ~/.my.cnf or /etc/my.cnf under #Logging

#log-output                     = FILE
#slow-query-log                 = 1
#slow-query-log-file            = /var/lib/mysqllogs/slow-log
#long-query-time                = 2
#log-queries-not-using-indexes  = 1

and restart the server.

Use mysqldumpslow to quickly parse through huge log files, as below.

mysqldumpslow /var/lib/mysqllogs/slow-log


No comments:

Post a Comment