[mysqld]
set-variable=long_query_time=1
log-slow-queries=/var/log/mysql/log-slow-queries.log
2. Perform following steps:
mkdir /var/log/mysql
touch /var/log/mysql/log-slow-queries.log
chown mysql.mysql -R /var/log/mysql
3. Restart mysql. /etc/init.d/mysqld restart
4. Now you can use mysqlsla tool to check the slow queries. Here are the steps.
cd /usr/src
wget http://hackmysql.com/scripts/mysqlsla-2.03.tar.gz
tar -xvzf mysqlsla-2.03.tar.gz
cd mysqlsla-2.03/bin
5. Execute following command :
./mysqlsla -lt slow --sort t_sum --top 5 /var/log/mysql/mysqld.slow
Now you'll able to see the results :) Contact developer to optimize the code.
optimize command is used to optimize the table. Here it is:
mysql>optimize table table_name;
check whether slow log has enabled or not.
mysql> SHOW VARIABLES like "%slow%"; //if not
mysql> SET @log_slow_queries=1;
Again restart mysql and use above tool after few minutes to check log.
By : singlehop.com

Responses
0 Respones to "How to check mysql slow queries or which queries are consuming cpu resources?"
Post a Comment
»Thank you for reading this article
If you have questions or comments, please leave a comment
»You can click on the Subscribe by email to subscribe comments of this post
»You can register directly link pictures, mp3, video on the comment form.
»You may use some HTML tags such
»Please post comments polite and typing accented Vietnamese if possible
»Thank the good faith comment