MySQL: 查看一次SQL的执行时间都花在哪些环节上

select @@profiling  -- 看看当前的session的profiling打开没有

set profiling = 1  -- 如果没打开,打开一下 


 -- 执行一些sql 
select count(*) ... 

select * from ...


show profiles -- 查看所有已执行的profile

show profile for query 2  -- 看看刚才某条sql执行的具体时间拆分,2是个某个query id 


show profile cpu for query 2  -- 看看刚才某条sql执行的具体时间拆分,并加上相应的cpu信息

posted on 2018-01-19 16:58  会学习的猪  阅读(326)  评论(0)    收藏  举报

导航