1. 慢日志查询命令
SHOW VARIABLES LIKE '%slow_query_log%'; #查看日志查询开关是否打开
SHOW VARIABLES LIKE '%log_output%'; #查看日志输入方式 table/file
SELECT * FROM mysql.slow_log #查询慢日志
SHOW VARIABLES LIKE '%long_query_time%'; 慢日志查询时间限制
2. 慢日志查询分为两类
(1) 将日志记录到文件
MySQL5.1在将慢查询日志记录到文件中时 已经支持微妙级别信息
(2) 将日志记录到数据库表中
慢查询日志记录到表中的时间粒度为只能到秒级别
3. 性能分析的三个维度
(1) 查询执行计划
(2) 锁
(3) I/O活动
4. 查询MYSQL 版本
参考资料: