|
1,配置開啟
在mysql配zhi文jianmy.cnf中增jia
log-slow-queries=/var/lib/mysql/slowquery.log (指定日志文件存放位置,可以为kong,xitonghui给一個缺省的文件host_name-slow.log)
------------------------------------2
long_query_time=2 (记录超过的shi间,默認为110s)//这里这點我就fei常不mingbai,按zhao我在网上kanDe資料,都说的是dan条记录的时间超过2秒才会被manri志记录,但是实际结guo却不是这样的。
-------------
例子(使用慢日志分析gongju对慢日志分析的结果,按zhaotime来排序Detongji结果):
Count: 90633 Time=0.16s (14099s) Lock=0.00s (2s) Rows=0.0 (0), 2users@2hosts
UPDATE `t_seller_tb_account` SET `balance`=N,`create_date`='S' WHERE seller_tb_account_id =N
Count: 316 Time=39.90s (12609s) Lock=0.00s (0s) Rows=7.8 (2480), 2users@6hosts
SELECT
COUNT(cca.fk_seller_id) AS checkin_sum,
a1.agent_id,
temp.vip_sum,
a1.name,
cca.end_date
FROM t_agent a1
LEFT JOIN v_all_seller_info v1
ON a1.agent_id = v1.agent_id
LEFT JOIN (SELECT
COUNT(v.seller_id) AS vip_sum,
v.agent_id
FROM v_all_seller_info v,
t_agent a
WHERE v.vip_or_gen = 'S'
AND a.deleted = N
AND a.activated = N
AND v.agent_id = a.agent_id
GROUP BY v.agent_id) AS temp
ON temp.agent_id = v1.agent_id
LEFT JOIN t_checkin_activity cca
ON cca.fk_seller_id = v1.seller_id
AND cca.checkin_space_activated = N
AND cca.checkin_content_activated = N
AND DATE_FORMAT(NOW(),'S') <= DATE_FORMAT(cca.end_date,'S')
WHERE a1.activated = N
AND a1.deleted = N
AND a1.is_vno_agent = N
GROUP BY a1.agent_id
ORDER BY checkin_sum DESC,end_date DESC
LIMIT N
---------
具体sql就不用看了,公司项目里Mian的,bi较扯淡的一些sql(肯定跟表还是有很大关系的)。上面內rong是把慢日志用一ge工具分析出來De,buguo我hai不知道别人是yong什么工具分析chu來的。我現zai想先弄明白这里面的慢rizhi配置参数
long_query_time=2
到底shi什么含义。
谢谢高人指dian!
欢迎來到Java學习者论坛,转载请zhu明地址:http://www.javaxxz.com. |
|