“Mysql 高性能笔记”的版本间的差异
来自Alex's wiki
(→使用SHOW PROFILE) |
(→使用SHOW PROFILE) |
||
| 第7行: | 第7行: | ||
show profiles; | show profiles; | ||
show profile for query 1; | show profile for query 1; | ||
| − | <pre> | + | </pre> |
以上是默认输出,若要手动则执行以下语句: | 以上是默认输出,若要手动则执行以下语句: | ||
<pre> | <pre> | ||
2016年8月31日 (三) 03:48的版本
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;