show profile 开启权限

定义:显示sql执行过程中各个环节的消耗情况,例如cpu使用情况,打开表、检查权限、执行优化器、返回数据等分别用了多长时间,可以分析语句执行慢的瓶颈在哪。

如果要使用这个命令首先要设置profiling为on,mysql默认设置为off;

select @@profiling; -- 查看profiling权限是否开启

set profiling =1; -- 设置打开profiling 或 set profiling=on;

set profiling=0; --设置关闭profiling 或 set profiling=off;

show profile;-- 查看查询操作的时间

原文地址:https://www.cnblogs.com/sweetorangezzz/p/12889334.html