mysql 调优可以从这个四个方面来看

1.性能监控
1.1 show profile for query n 查看具体的sql语句各阶段执行时间
show profiles;
show profile for query n;
![在这里插入图片描述]()
1.2 performance schema 监控mysql 整个服务器中发生的各种事件。
- performance schema 表中的数据不会持久化的磁盘,是在内存中。
- performance schema 表使用performance schema 存储引擎。
- performance schema 监控mysql 整个服务器中发生的各种事件。
1.3 show processlist; 查看当前数据库服务器连接的线程个数

2. schema 与数据类型的优化

3. 执行计划 explain
https://dev.mysql.com/doc/refman/8.0/en/explain-output.html
4. 通过索引进行优化
索引覆盖,索引下推,具体另文细讲
5.其他相关基础知识
mysql 日志体系
MySQL的日志体系有如下几种分类:
- 错误日志
- 查询日志
- 慢查询日志
- 事务日志(Redo log/undo log)
- 二进制日志
- 中继日志
mysql 执行流程

优化器的两种优化方式 RBO,CBO,主流CBO。