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

MySQL 5.5中SHOW PROFILE、SHOW PROFILES語句怎么用

166次閱讀
沒有評論

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

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

SHOW PROFILE 和 SHOW PROFILES 語句顯示 MySQL 數據庫語句的資源消耗情況。
需要注意的是:這兩條命令均顯示當前會話的 SQL 資源消耗情況,不能顯示其他會話的資源消耗情況。

– 需要打開 Profiling 參數

mysql show variables like profil%
+————————+——-+
| Variable_name          | Value |
+————————+——-+
| profiling              | OFF   |
| profiling_history_size | 15    |
+————————+——-+
2 rows in set (0.10 sec)

mysql set profiling = 1;
Query OK, 0 rows affected (0.00 sec)

mysql show session variables like profil%
+————————+——-+
| Variable_name          | Value |
+————————+——-+
| profiling              | ON    |
| profiling_history_size | 15    |
+————————+——-+
2 rows in set (0.00 sec)

SHOW PROFILES 顯示最近發送到 MySQL 服務器的語句。顯示語句的條數由 profiling_history_size 參數設定,默認值是 15,最大值是 100,將參數的值設為 0 并不會關閉 profiling 功能。除了 SHOW PROFILE 和 SHOW PROFILES,其他的語句都會顯示在列表中。
SHOW PROFIL 會顯示一條語句的具體信息。如果沒有指定 FOR QUERY 語句,輸出結果會顯示最后執行的語句。如果指定了 FOR QUERY 和語句編號,則會顯示指定語句的信息。語句編號對應 SHOW PROFILES 顯示結果中的 Query_ID 字段。LIMIT 語句會限制輸出的行數。默認,SHOW PROFILE 語句只顯示狀態和運行時間這兩個字段,狀態字段和 SHOW PROCESSLIST 里面的狀態字段相似。

– 示例

mysql select * from t9;

mysql select * from t_arc1 limit 10;

mysql show profiles;
+———-+————+——————————-+
| Query_ID | Duration   | Query                         |
+———-+————+——————————-+
|        1 | 0.00019375 | select * from t9              |
|        2 | 0.00023150 | select * from t_arc1 limit 10 |
+———-+————+——————————-+
2 rows in set (0.00 sec)

mysql show profile for query 2;
+———————-+———-+
| Status               | Duration |
+———————-+———-+
| starting             | 0.000058 |
| checking permissions | 0.000005 |
| Opening tables       | 0.000011 |
| System lock          | 0.000006 |
| init                 | 0.000015 |
| optimizing           | 0.000003 |
| statistics           | 0.000011 |
| preparing            | 0.000010 |
| executing            | 0.000002 |
| Sending data         | 0.000094 |
| end                  | 0.000003 |
| query end            | 0.000003 |
| closing tables       | 0.000003 |
| freeing items        | 0.000007 |
| logging slow query   | 0.000001 |
| cleaning up          | 0.000002 |
+———————-+———-+
16 rows in set (0.00 sec)

mysql show profile cpu for query 2;
+———————-+———-+———-+————+
| Status               | Duration | CPU_user | CPU_system |
+———————-+———-+———-+————+
| starting             | 0.000058 | 0.000000 |   0.000000 |
| checking permissions | 0.000005 | 0.000000 |   0.000000 |
| Opening tables       | 0.000011 | 0.000000 |   0.000000 |
| System lock          | 0.000006 | 0.000000 |   0.000000 |
| init                 | 0.000015 | 0.000000 |   0.000000 |
| optimizing           | 0.000003 | 0.000000 |   0.000000 |
| statistics           | 0.000011 | 0.000000 |   0.000000 |
| preparing            | 0.000010 | 0.000000 |   0.000000 |
| executing            | 0.000002 | 0.000000 |   0.000000 |
| Sending data         | 0.000094 | 0.000000 |   0.000000 |
| end                  | 0.000003 | 0.000000 |   0.000000 |
| query end            | 0.000003 | 0.000000 |   0.000000 |
| closing tables       | 0.000003 | 0.000000 |   0.000000 |
| freeing items        | 0.000007 | 0.000000 |   0.000000 |
| logging slow query   | 0.000001 | 0.000000 |   0.000000 |
| cleaning up          | 0.000002 | 0.000000 |   0.000000 |
+———————-+———-+———-+————+
16 rows in set (0.00 sec)

– 查看 SQL 解析執行過程中每個步驟對應的源碼的文件、函數名以及具體的源文件行數

MariaDB [test] show profile source for query 31\G
*************************** 1. row ***************************
         Status: starting
       Duration: 0.000034
Source_function: NULL
    Source_file: NULL
    Source_line: NULL
*************************** 2. row ***************************
         Status: checking permissions
       Duration: 0.000005
Source_function: check_access
    Source_file: sql_parse.cc
    Source_line: 6043

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

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-27發表,共計3558字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 亳州市| 正阳县| 普安县| 黔东| 扶沟县| 临沭县| 嘉兴市| 万年县| 本溪| 潞西市| 营口市| 聂拉木县| 株洲市| 延安市| 洞头县| 尚义县| 河池市| 江川县| 合山市| 沅陵县| 水城县| 万宁市| 东安县| 乌兰浩特市| 泽库县| 法库县| 六安市| 永丰县| 巢湖市| 和静县| 米泉市| 洪江市| 抚顺市| 香格里拉县| 南漳县| 应城市| 武安市| 洪江市| 侯马市| 平果县| 安徽省|