您好,登錄后才能下訂單哦!
本篇內容主要講解“怎么使用MySQL profile”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“怎么使用MySQL profile”吧!
剖析單條查詢 profile:
mysql> show variables like '%prof%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| have_profiling | YES |
| profiling | OFF |
| profiling_history_size | 15 |
+------------------------+-------+
3 rows in set (0.00 sec)
mysql> set profiling = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show variables like '%prof%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| have_profiling | YES |
| profiling | ON |
| profiling_history_size | 15 |
+------------------------+-------+
3 rows in set (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select count(*) from user;
+----------+
| count(*) |
+----------+
| 4 |
+----------+
1 row in set (0.03 sec)
mysql> show profiles;
+----------+------------+------------------------------+
| Query_ID | Duration | Query |
+----------+------------+------------------------------+
| 1 | 0.00103425 | show variables like '%prof%' |
| 2 | 0.00016325 | SELECT DATABASE() |
| 3 | 0.00049450 | show databases |
| 4 | 0.00039775 | show tables |
| 5 | 0.02702100 | select count(*) from user |
+----------+------------+------------------------------+
5 rows in set, 1 warning (0.00 sec)
mysql> show profile for query 5;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| starting | 0.000090 |
| checking permissions | 0.000012 |
| Opening tables | 0.000030 |
| init | 0.000035 |
| System lock | 0.000016 |
| optimizing | 0.025417 |
| executing | 0.000054 |
| end | 0.000551 |
| query end | 0.000020 |
| closing tables | 0.000021 |
| freeing items | 0.000732 |
| cleaning up | 0.000045 |
+----------------------+----------+
12 rows in set, 1 warning (0.00 sec)
到此,相信大家對“怎么使用MySQL profile”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。