高性能MySQL(三):服务器性能剖析
select * from c LEFT JOIN c100w on c.id=c100w.id; -- 联合查询 show PROFILES; -- 查看查询耗时 select * from c; show PROFILE for query 1 ; set @query_id=282; 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
select * from c LEFT JOIN c100w on c.id=c100w.id; -- 联合查询 show PROFILES; -- 查看查询耗时 select * from c; show PROFILE for query 1 ; set @query_id=282; 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
flush status; -- 清除表缓存 show STATUS where variable_name like 'Handler%' or variable_name like 'Created%' -- 计数器
select event_name,count_star,sum_timer_wait from `performance_schema`.events_waits_summary_global_by_event_name order by sum_timer_wait desc LIMIT 5
原创不易,转载请声明 bindot
https://www.cnblogs.com/bindot/