共計 1125 個字符,預計需要花費 3 分鐘才能閱讀完成。
如何進行性能分析 profiling,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
使用 mysql 自帶的工具 profiling
1. 查看是否打開
mysql show variables like %pro%
+—————————+——-+
| Variable_name | Value |
+—————————+——-+
| have_profiling | YES |
| profiling | OFF |
| profiling_history_size | 15 |
| protocol_version | 10 |
| proxy_user | |
| slave_compressed_protocol | OFF |
| stored_program_cache | 256 |
+—————————+——-+
7 rows in set (0.00 sec)
2. 默認是關閉的
打開它
set profiling=1;
3. 使用
select * from corp_base_par where res_date=330000 limit 1;
mysql show profiles;
+———-+————+———————————————————–+
| Query_ID | Duration | Query |
+———-+————+———————————————————–+
| 1 | 0.00008975 | set profiling=1 |
| 2 | 0.00088450 | select * from corp_base_par where res_date=330000 limit 1 |
+———-+————+———————————————————–+
2 rows in set (0.00 sec)
顯示了 這條 sql 的具體消耗時間
看完上述內容,你們掌握如何進行性能分析 profiling 的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注丸趣 TV 行業資訊頻道,感謝各位的閱讀!