這篇文章主要為大家展示了“MySQL中Performance_schema SQL執(zhí)行統(tǒng)計(jì)的示例分析”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“Mysql中Performance_schema SQL執(zhí)行統(tǒng)計(jì)的示例分析”這篇文章吧。
創(chuàng)新互聯(lián)專注于網(wǎng)站建設(shè)|成都網(wǎng)站維護(hù)|優(yōu)化|托管以及網(wǎng)絡(luò)推廣,積累了大量的網(wǎng)站設(shè)計(jì)與制作經(jīng)驗(yàn),為許多企業(yè)提供了網(wǎng)站定制設(shè)計(jì)服務(wù),案例作品覆蓋假山制作等行業(yè)。能根據(jù)企業(yè)所處的行業(yè)與銷售的產(chǎn)品,結(jié)合品牌形象的塑造,量身建設(shè)品質(zhì)網(wǎng)站。
查看執(zhí)行最頻繁TOP SQL:
可以解決問(wèn)題:
1.SQL的執(zhí)行次數(shù)
2.全表掃描
3.臨時(shí)表
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 執(zhí)行性能報(bào)告
開(kāi)啟SQL的性能收集
use performance_schema;
update setup_consumers set enabled='YES' where name IN ('events_statements_history','events_statements_current','statements_digest');
清空SQL性能數(shù)據(jù)
truncate table events_statements_current;
truncate table events_statements_history;
truncate table events_statements_summary_by_digest;
do sleep(60);
統(tǒng)計(jì)SQL的執(zhí)行比例
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;
關(guān)閉SQL的性能收集:
update setup_consumers set enabled='NO' where name IN ('events_statements_history','events_statements_current','statements_digest');
以上是“Mysql中Performance_schema SQL執(zhí)行統(tǒng)計(jì)的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!