学习内容:
- profiles:查询mysql运行的时间
- performance_schema
profiles
设置属性: mysql> set profiling = 1 ;
查看sql运行时间:show profiles;
查询sql运行的具体时间:show profile;
查询具体某条数据运行时间:4为show profiles;运行的Query_ID
show profile all for query 4;
官网地址:
MySQL :: MySQL 8.0 Reference Manual :: 13.7.7.30 SHOW PROFILE Statement
不建议使用SHOW PROFILE和SHOW PROFILES语句;预计它们将在未来的MySQL版本中删除。改为使用性能模式;请参阅第27.19.1节“使用性能模式进行查询分析”。
performance_schema
使用show performance_schema 数据库实时检查server内部运行情况,监视性能,查看内存耗费资源。
开启:performance_schema=ON
查看:SHOW VARIABLES LIKE 'performance_schema';
官网地址:MySQL :: MySQL 8.0 Reference Manual :: 27.1 Performance Schema Quick Start
查看当前连接:show processlist;