MySQL:日志速度慢;追加CPU使用率 [英] MySQL: Slow log; append CPU usage
问题描述
我启用了MySQL慢日志功能: http ://dev.mysql.com/doc/refman/5.1/zh-CN/slow-query-log.html
I have the MySQL slow log feature enabled: http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html
但是有时由于较高的CPU负载,query_times很高.
But sometimes the query_times are high simply due to high CPU load.
如何将当前CPU负载附加到MySQL慢日志(写入文件)中的每个条目?
How can I append the current CPU load to each entry in the MySQL slow log (it writes to a file)?
推荐答案
由于查询速度慢,CPU可能很高.
The CPU may be high due to the slow query.
MySQL不会监视您的CPU,因此您将需要一个第三方监视工具,并将CPU处于高状态的时间与查询(已记录)的运行时间进行比较.
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.
我使用的AWS具有良好的监视功能,当CPU处于高电平时会收到警报,然后我可以跟踪慢速查询日志,看看是什么原因引起的.
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.
希望能有所帮助.但是我的猜测是由于查询导致CPU占用率很高,而不是由于CPU导致查询速度变慢.只是一个猜想.
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.
这篇关于MySQL:日志速度慢;追加CPU使用率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!