Chinaunix首页 | 论坛 | 博客
  • 博客访问: 76609
  • 博文数量: 24
  • 博客积分: 2035
  • 博客等级: 大尉
  • 技术积分: 175
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-01 12:40
文章分类

全部博文(24)

文章存档

2016年(2)

2010年(1)

2009年(17)

2008年(4)

我的朋友

分类: Mysql/postgreSQL

2009-09-01 21:52:58

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
阅读(1030) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~