Mysql查看sql的执行时间

在mysql中我们可以通过以下的方法去了解sql执行的具体步骤以及之间,这可以为

1. 查看profiling的状态,1为开启,默认处于关闭状态

SELECT @@profiling;

2. 开启
SET profiling = 1;


3. 执行sql语句

4. 显示 profiles的信息,格式看着不爽的可以在后面加上\G

show profiles;
show profiles\G;

5. 具体查看某一次的就可以通过指定query_id的方式

show profile for query 2;

show profile block io,cpu for query 2;

猜你喜欢

转载自zhao-rock.iteye.com/blog/2024135