久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

MySQL中profiling有什么用

157次閱讀
沒有評論

共計 2297 個字符,預計需要花費 6 分鐘才能閱讀完成。

這篇文章將為大家詳細講解有關 MySQL 中 profiling 有什么用,丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

    MySQL5.0 版本之后開放了 profiling 功能,通過此功能可以查詢某個 SQL 的詳細執行計劃。
1、開啟 profiling
mysql show variables like %profil%
+————————+——-+
| Variable_name          | Value |
+————————+——-+
| have_profiling          | YES   |
| profiling                    | ON    |
| profiling_history_size | 15    |
+————————+——-+
2、執行 SQL,進行測試
mysql select * from xcredit.tb_sync_job_bak;
3、查看 profiles
mysql show profiles;
+———-+————+——————————————————————————+
| Query_ID | Duration   | Query                                                                        |
+———-+————+——————————————————————————+
|        1 | 0.00009600 | set global profiling=1                                                       |
|        2 | 0.00218100 | show variables like %profil%                                               |
|        3 | 0.04091100 | select * from xcredit.tb_sync_job_bak where lid 1000 group by lid limit 5000 |
|        4 | 0.00019800 | select * from xcredit.tb_sync_job_bak where lid 1000 group by lid            |
|        5 | 0.16355550 | select * from xcredit.tb_sync_job_bak where lid 1000                         |
|        6 | 0.00230025 | show variables like %profil%                                               |
|        7 | 0.00014375 | select * from xcredit.tb_sync_job_bak group by lid%20 order by lid           |
|        8 | 0.00013600 | select * from xcredit.tb_sync_job_bak group by lid%20 order by 1             |
|        9 | 0.00013375 | select * from xcredit.tb_sync_job_bak group by lid%20                        |
|       10 | 0.26594500 | select * from xcredit.tb_sync_job_bak                                        |
+———-+————+——————————————————————————+
4、查看執行計劃
mysql show profile for query 10;
+———————-+———-+
| Status               | Duration |
+———————-+———-+
| starting             | 0.000053 |
| checking permissions | 0.000005 |
| Opening tables       | 0.000014 |
| init                 | 0.000014 |
| System lock          | 0.000006 |
| optimizing           | 0.000003 |
| statistics           | 0.000010 |
| preparing            | 0.000009 |
| executing            | 0.000001 |
| Sending data         | 0.265498 |
| end                  | 0.000009 |
| query end            | 0.000010 |
| closing tables       | 0.000008 |
| freeing items        | 0.000258 |
| logging slow query   | 0.000036 |
| cleaning up          | 0.000011 |
+———————-+———-+
此查詢返回八萬多行數據,返回數據量較大,因此出現 sending data。

關于“MySQL 中 profiling 有什么用”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-27發表,共計2297字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 伊川县| 化州市| 麻城市| 双城市| 枣阳市| 西畴县| 高唐县| 洱源县| 噶尔县| 中牟县| 故城县| 金山区| 龙岩市| 富顺县| 兴宁市| 三台县| 高雄县| 乌审旗| 博兴县| 苍南县| 华池县| 普陀区| 金乡县| 驻马店市| 马公市| 长垣县| 雅江县| 铜梁县| 三穗县| 云南省| 陕西省| 盐池县| 秦安县| 扎兰屯市| 广德县| 遂宁市| 封丘县| 出国| 防城港市| 嘉鱼县| 西林县|