mysql profile參數

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
mysql查看系統性能的一個好東西
在mysql5.0.37以後纔有

mysql> select @@profiling;
+-------------+
| @@profiling |
+-------------+
|           0 |
+-------------+
1 row in set (0.00 sec)

mysql> SET profiling = 1;
Query OK, 0 rows affected (0.00 sec)
使profile選項生效

mysql> show profiles;
Empty 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(*) |
+----------+
|       22 |
+----------+
1 row in set (0.00 sec)

mysql> show profiles;
+----------+------------+---------------------------+
| Query_ID | Duration   | Query                     |
+----------+------------+---------------------------+
|        1 | 0.00000700 | SELECT DATABASE()         |
|        2 | 0.00030600 | show databases            |
|        3 | 0.00000600 | show tables               |
|        4 | 0.00010700 | select count(*) from user |
+----------+------------+---------------------------+
4 rows in set (0.01 sec)

mysql> show profile;
+--------------------------------+----------+
| Status                         | Duration |
+--------------------------------+----------+
| (initialization)               | 0.000004 |
| checking query cache for query | 0.000036 |
| Opening tables                 | 0.000006 |
| System lock                    | 0.000015 |
| Table lock                     | 0.000006 |
| init                           | 0.000007 |
| optimizing                     | 0.000006 |
| executing                      | 0.000012 |
| end                            | 0.000003 |
| query end                      | 0.000002 |
| freeing items                  | 0.000005 |
| closing tables                 | 0.000004 |
| logging slow query             | 0.000001 |
+--------------------------------+----------+
13 rows in set (0.00 sec)

mysql> show profile cpu,memory for query 4;
+--------------------------------+----------+----------+------------+
| Status                         | Duration | CPU_user | CPU_system |
+--------------------------------+----------+----------+------------+
| (initialization)               | 0.000004 | 0        | 0          |
| checking query cache for query | 0.000036 | 0        | 0          |
| Opening tables                 | 0.000006 | 0        | 0          |
| System lock                    | 0.000015 | 0        | 0          |
| Table lock                     | 0.000006 | 0        | 0          |
| init                           | 0.000007 | 0        | 0          |
| optimizing                     | 0.000006 | 0        | 0          |
| executing                      | 0.000012 | 0        | 0          |
| end                            | 0.000003 | 0        | 0          |
| query end                      | 0.000002 | 0        | 0          |
| freeing items                  | 0.000005 | 0        | 0          |
| closing tables                 | 0.000004 | 0        | 0          |
| logging slow query             | 0.000001 | 0        | 0          |
+--------------------------------+----------+----------+------------+
13 rows in set (0.00 sec)

不錯把  根多的內容要看
help mysql profile
有了這個工具,查看系統性能還是很有用的。

 
發佈了28 篇原創文章 · 獲贊 0 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章