Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: Slow log; append CPU usage

I have the MySQL slow log feature enabled: http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

But sometimes the query_times are high simply due to high CPU load.

How can I append the current CPU load to each entry in the MySQL slow log (it writes to a file)?

like image 266
Zeno Avatar asked Nov 13 '22 11:11

Zeno


1 Answers

The CPU may be high due to the slow query.

MySQL does not monitor your CPU, so you are going to need a 3rd party monitoring tool and compare the times that CPU is high to the times the query (that is logged) is running.

I use AWS, which has some nice monitoring, and I get an alert when the CPU is high, then I can tail the Slow Query Log and see which ones are causing it.

Hope that helps some. But my guess is the CPU is high due to the query and not that the query is slow due to the CPU. Just a guess tho.

like image 169
chantheman Avatar answered Dec 10 '22 07:12

chantheman