Mysql profile 的應用
如何透過profile來發現語句的開銷
構造場景:
開啟一個回話,執行語句
lock table film_text read;
開啟另外一個回話,執行下面語句:
root@sakila 07:51:14>show variables like '%profil%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| have_profiling | YES |
| profiling | OFF |
| profiling_history_size | 15 |
+------------------------+-------+
3 rows in set (0.01 sec)
root@sakila 07:52:38>set profiling=1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
root@sakila 07:52:45>update film_text set title='test' where film_id=1003;
Query OK, 0 rows affected (11.02 sec)
Rows matched: 1 Changed: 0 Warnings: 0
root@sakila 07:53:18>show profiles;
+----------+-------------+------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+-------------+------------------------------------------------------+
| 1 | 11.02395150 | update film_text set title='test' where film_id=1003 |
+----------+-------------+------------------------------------------------------+
1 row in set, 1 warning (0.01 sec)
root@sakila 07:53:26>show profile for query 1;
+------------------------------+-----------+
| Status | Duration |
+------------------------------+-----------+
| starting | 0.000793 |
| checking permissions | 0.000032 |
| Opening tables | 0.000087 |
| init | 0.000026 |
| System lock | 0.000025 |
| Waiting for table level lock | 11.018648 |
| System lock | 0.000770 |
| updating | 0.002947 |
| end | 0.000077 |
| query end | 0.000069 |
| closing tables | 0.000062 |
| freeing items | 0.000253 |
| cleaning up | 0.000163 |
+------------------------------+-----------+
13 rows in set, 1 warning (0.00 sec)
可以看到開銷是在這個waiting table lock.
貌似 show profiles 只能顯示本回話執行的sql語句的情況,即使設定了global profiling=1
所以如果要調優一組sql, 那麼把這一組sql放到一個回話中執行,然後執行show profiles 檢視每條語句的執行時間,並且進一步分析開銷在什麼地方。
構造場景:
開啟一個回話,執行語句
lock table film_text read;
開啟另外一個回話,執行下面語句:
root@sakila 07:51:14>show variables like '%profil%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| have_profiling | YES |
| profiling | OFF |
| profiling_history_size | 15 |
+------------------------+-------+
3 rows in set (0.01 sec)
root@sakila 07:52:38>set profiling=1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
root@sakila 07:52:45>update film_text set title='test' where film_id=1003;
Query OK, 0 rows affected (11.02 sec)
Rows matched: 1 Changed: 0 Warnings: 0
root@sakila 07:53:18>show profiles;
+----------+-------------+------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+-------------+------------------------------------------------------+
| 1 | 11.02395150 | update film_text set title='test' where film_id=1003 |
+----------+-------------+------------------------------------------------------+
1 row in set, 1 warning (0.01 sec)
root@sakila 07:53:26>show profile for query 1;
+------------------------------+-----------+
| Status | Duration |
+------------------------------+-----------+
| starting | 0.000793 |
| checking permissions | 0.000032 |
| Opening tables | 0.000087 |
| init | 0.000026 |
| System lock | 0.000025 |
| Waiting for table level lock | 11.018648 |
| System lock | 0.000770 |
| updating | 0.002947 |
| end | 0.000077 |
| query end | 0.000069 |
| closing tables | 0.000062 |
| freeing items | 0.000253 |
| cleaning up | 0.000163 |
+------------------------------+-----------+
13 rows in set, 1 warning (0.00 sec)
可以看到開銷是在這個waiting table lock.
貌似 show profiles 只能顯示本回話執行的sql語句的情況,即使設定了global profiling=1
所以如果要調優一組sql, 那麼把這一組sql放到一個回話中執行,然後執行show profiles 檢視每條語句的執行時間,並且進一步分析開銷在什麼地方。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/674865/viewspace-2135270/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle之profile的應用Oracle
- oracle之 profile的應用Oracle
- MySQL效能分析工具之PROFILEMySql
- MySQL Profile在5.7的簡單測試MySql
- MySQL Profile檢視SQL的資源使用MySql
- MYSQL SHOW PROFILE(剖析報告)的檢視MySql
- MySQL高階知識——Show ProfileMySql
- Mysql調優之profile詳解MySql
- HugePage在mysql中的應用MySql
- Mysql的DATE_FORMAT()應用MySqlORM
- MySQL:COUNT(*) profile optimizing階段慢MySql
- MySQL使用profile分析語句效能消耗MySql
- MySQL應用優化MySql優化
- 編寫高效的MySQL應用(轉)MySql
- 使用V8和node輕鬆profile分析nodejs應用程式NodeJS
- MySQL調優效能監控之show profileMySql
- linux下 /etc/profile、~/.bash_profile ~/.profile的執行過程Linux
- MySQL壓縮表的一種應用MySql
- MySQL 5.5 SHOW PROFILE、SHOW PROFILES語句介紹MySql
- mysql常見的查詢語句的應用MySql
- Oracle profile的使用Oracle
- sql profile的使用SQL
- MAVEN中的profileMaven
- MySQL索引理解和應用MySql索引
- Mysql資料庫應用(一)MySql資料庫
- 用PyCharm Profile分析非同步爬蟲效率PyCharm非同步爬蟲
- 用sql profile來固定執行計劃SQL
- MySQL Proxy應用入門(1)--安裝MySQL ProxyMySql
- 【Mysql】mysqldump 匯出各種場景的應用MySql
- centos+docker+mysql 配置與應用CentOSDockerMySql
- Mysql配置從庫延遲應用MySql
- [精]mysql聯合主鍵應用MySql
- Bluetooth的profile總結
- 原創 利用TCA-API建PARTY的PROFILE以及PROFILE AMTAPI
- MySQL Proxy應用入門(2)--MySQL Proxy配置選項MySql
- Oracle profileOracle
- sql profileSQL
- MySQL實際應用中遇到的鎖問題薦MySql