Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Enabling slow queries in MySQL  (Read 3106 times)

0 Members and 1 Guest are viewing this topic.

Leo.Prince

  • Guest
Enabling slow queries in MySQL
« on: November 03, 2013, 08:02:20 pm »
Hi,

Slow queries are very useful in optimizing the databases and locating bad queries. The slow query log consists of SQL statements that took more than long_query_time seconds to execute and (as of MySQL 5.1.21) required at least min_examined_row_limit rows to be examined. The parameters long_query_time and min_examined_row_limit are MySQL variables comes as set with each MySQL version and package. You can have further awareness from the following links

http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_long_query_time

http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_min_examined_row_limit

Add the following to /etc/my.cnf file to enable the slow query log:

Code: [Select]
log-slow-queries=/var/lib/mysql/slow.log
Then create the log file with required permissions too...

Code: [Select]
touch /var/lib/mysql/slow.log
chmod 660 /var/lib/mysql/slow.log
chown mysql:mysql /var/lib/mysql/slow.log

Done... !! Thanks  8)