分析海量数据:
(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中