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;