MySQL SQL语句性能分析

2019-12-12 16:52栏目:b888计算机

MySQL SQL语句质量分析

 

set profiling = 1;

select * from g_staff;

 

show profiles

  www.2cto.com  

SHOW profile CPU,BLOCK IO  FOR query 88;

 

select * from NFORMATION_SCHEMA.PROFILING

 

将 MySQL’s SHOW PROFILES 命令的结果转成切合阅读的格式

 

SET @query_id := 5;

SELECT

     STATE,

     SUM(DURATION) AS Total_R,

     ROUND(

          100 * SUM(DURATION) / (

               SELECT

                    SUM(DURATION)

               FROM

                    INFORMATION_SCHEMA.PROFILING

               WHERE  www.2cto.com  

                    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;

 

 

作者 bengda

SQL语句质量剖判 set profiling = 1; select * from g_staff; show profiles www.2cto.com SHOW profile CPU,BLOCK IO FOR query 88; select * from NFORMATION_SCHEMA.PROFILING 将...

版权声明:本文由b888博一-sbf老虎机发布于b888计算机,转载请注明出处:MySQL SQL语句性能分析