“Mysql 高性能笔记”的版本间的差异

来自Alex's wiki
跳转至: 导航搜索
(创建页面,内容为“ ==3.3.2 剖析单条性能== ===使用SHOW PROFILE=== 在会话级别使用 set profiling = 1; show profiles; show profile for query 1; 以上是默认输出,若...”)
 
使用SHOW PROFILE
第3行: 第3行:
 
===使用SHOW PROFILE===
 
===使用SHOW PROFILE===
 
在会话级别使用
 
在会话级别使用
 +
 
set profiling = 1;
 
set profiling = 1;
 +
 
show profiles;
 
show profiles;
 +
 
show profile for query 1;
 
show profile for query 1;
  

2016年8月31日 (三) 03:47的版本

3.3.2 剖析单条性能

使用SHOW PROFILE

在会话级别使用

set profiling = 1;

show profiles;

show profile for query 1;

以上是默认输出,若要手动则执行以下语句:

select state ,sum(duration) as total_r ,
      round(
        100 * sum(duration) /
          (select sum(duration)
           from information_schema.profiling
           where query_id = @query_id
        ),2 ) as pct_r ,
      count(*) as calls,
      sum(duration) / count(*) as "R/Call"
     from information_schema.profiling
     where query_id =  @query_id
     group by state
     order by total_r desc;