- 论坛徽章:
- 0
|
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
有了这个工具,查看系统性能还是很有用的。
本文来自CSDN博客,转载请标明出处:
http://blog.csdn.net/1satellite1/archive/2008/04/06/2255508.aspx
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/44726/showart_2043350.html |
|