这篇文章主要为大家展示了“Mysql中Performance_schema SQL执行统计的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Mysql中Performance_schema SQL执行统计的示例分析”这篇文章吧。
查看执行最频繁TOP SQL:
可以解决问题:
1.SQL的执行次数
2.全表扫描
3.临时表
select digest_text as sql_text,count_star as exec_count,if(sum_no_good_index_used > 0 or sum_no_index_used > 0, '*', '') as full_scan,sum_created_tmp_tables as tmp_tables,
sum_created_tmp_disk_tables as tmp_disk_tables,
sum_sort_rows as rows_sorted from events_statements_summary_by_digest where schema_name='ticket' and digest_text like 'select%' order by count_star desc limit 10;
生成mysql sql 执行性能报告
开启SQL的性能收集
use performance_schema;
update setup_consumers set enabled='YES' where name IN ('events_statements_history','events_statements_current','statements_digest');
清空SQL性能数据
truncate table events_statements_current;
truncate table events_statements_history;
truncate table events_statements_summary_by_digest;
do sleep(60);
统计SQL的执行比例
select now(),(count_star/(select sum(count_star) FROM events_statements_summary_by_digest) * 100) as pct, count_star as sql_exec, left(digest_text,150) as stmt, digest from events_statements_summary_by_digest order by 2 desc;
关闭SQL的性能收集:
update setup_consumers set enabled='NO' where name IN ('events_statements_history','events_statements_current','statements_digest');
以上是“Mysql中Performance_schema SQL执行统计的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。