myslq show profile

2020-05-22  本文已影响0人  simplerandom

show profile作用

能够查出最近15条SQL语句的运行状态(包含运行过程中执行了哪些操作,各占用了多长时间),以便开发者的分析。

开启

SHOW VARIABLES LIKE 'profiling';
SET profiling=ON;
SHOW VARIABLES LIKE 'profiling';

运行sql

随便运行几条SQL,以便于show prifiles的日志分析。

查看结果

show profiles;

诊断SQL

用于单独分析某条sql,查看某条sql的生命周期以及各占用多少时间。
SHOW PROFILE cpu, block io FOR QUERY id;

如果show profile ... for query id;出现了如下四个,则必须优化这条sql。
https://img.haomeiwen.com/i4582242/3eac8e5227d037b7.png?imageMogr2/auto-orient/strip|imageView2/2/w/954/format/webp

上一篇 下一篇

猜你喜欢

热点阅读