分析海量数据:
(1)profiles
show profiles; --默认关闭
show profiles like "%profiling%";
set profiling = on; -- 打开profiles
show profiles: 会记录所有在profiles开启之后的SQL查询语句所花费的时间。
缺点不够精确
(2)精确分析:sql诊断
show profile all for query 上一步查询的query_Id
show profile cpu, block io for query 上一步查询的Query_Id
(3)全局查询日志:记录开启之后的全部SQL语句。
show variables like "%general_log%";
set global general_log = 1; --开启全局日志
set global log_output = "general_log";
开启后,会被记录到mysql.general_log中
本文介绍了MySQL性能调优的方法,包括使用profiles记录SQL执行时间、利用sql诊断进行精确分析及开启全局查询日志来记录所有SQL语句。
221

被折叠的 条评论
为什么被折叠?



