Reputation: 79
How can I view mysql slow_query_log to see which query is taking too much time?
Upvotes: 3
Views: 5947
Reputation: 2222
If you're running mysqld < 5.2, your my.cnf may look like
log-slow-queries=/var/log/mysql/mysql-slow.log //where to store log
long_query_time=3 //quickest query to log
Upvotes: 0
Reputation: 92752
First, you need to check if it's enabled in your MySQL configuration (mysql.ini or mysql.cnf, depending on your system):
# enable slow log:
slow_query_log = 1
# log queries longer than n seconds:
long_query_time = 5
# where to log:
slow_query_log_file = /path/to/your/logs/mysql-slow.log
Restart your MySQL server, then watch the logfile using whatever program you like - tail
is the simplest:
tail -f /path/to/your/logs/mysql-slow.log
You may need to play a bit with the long_query_time
setting to find the limit where the volume of logging isn't too low or too high, but just right.
Upvotes: 4
Reputation: 51797
if you ask google for "slow_query_log", this is the first hit - explaining all you need to know. you have to enable it, set a filename you like (if it's already set, you can find the configuration in you my.ini
), start your queries and look ito that file...
Upvotes: 0
Reputation: 62369
Check the location of this log in my.ini file, and then open it in any text editor.
Upvotes: 0