SET @query_id = 52;
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 contract_review;#需要优化的SQL语句
SHOW PROFILES;#查找需要优化的SQL语句的queryId
SHOW PROFILE FOR QUERY 38;#查看该语句每一步具体执行时间
网友评论