目录
一.show profile分析SQL
Mysql从5.0.37版本开始增加了对show profiles和show profile语句的支持。show profiles能够在做SQL优化时帮助我们了解时间都耗费到哪里去了。。
通过have_profiling参数,能够看到当前MySQL是否支持profile :
-- 查看当前的MySQL是否支持profile
select @@have_profiling;
-- 如果不支持,则需要设置打开
set profiling=1;
通过profile,我们能够更清楚地了解sQL执行的过程。首先,我们可以执行一下一系列的操作
show databases;
use test_optimize;
show tables;
select * from `user` u where uid<2;
select count(*) from user;
执行完上述命令之后,再执行show prof