1、show profile(s) 查看语句的整个执行时间片
https://dev.mysql.com/doc/refman/8.0/en/show-profile.html
- set profiling=1
- show profile for query id
- show profile cpu for query id
2、show processlist 目前连接的客户端
3、Performance:session级别,不参与主从拷贝等,实时监控;采用生产+消费模式
https://dev.mysql.com/doc/refman/8.0/en/performance-schema-quick-start.html
3.1、是否开启
SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE='PERFORMANCE_SCHEMA'G
3.2、开启方式(仅可通过配置文件)
[mysqld]
performance_schema=ON
3.3、常见的几种操作
- 单表结构查询:SHOW CREATE TABLE performance_schema.setup_consumersG 开启所有事件收集:
- UPDATE performance_schema.setup_instruments SET ENABLED = 'YES', TIMED = 'YES';
- UPDATE performance_schema.setup_consumers SET ENABLED = 'YES';
- 服务器当前做什么:SELECT * FROM performance_schema.events_waits_currentG
- 文件操作实例:SELECT * FROM performance_schema.file_instancesG
- 查看启用了哪些工具:SELECT NAME, ENABLED, TIMED FROM performance_schema.setup_instruments;
四、查看状态
show status; show status like '%innodb%';
五、查看配置参数
show variables; show variables like '%log%';