mysql的sql性能分析器

来源:未知 责任编辑:责任编辑 发表时间:2014-05-26 11:02 点击:
author:skate
time:2012/02/17
 
mysql的sql性能分析器
 
MySQL 的SQL性能分析器主要用途是显示SQL执行的整个过程中各项资源的使用情况。分析器可以更好的展示
出不良SQL的性能问题所在。
 
mysql sql profile的使用方法
 
1.开启mysql sql profile
 
检查mysql sql profile是否启用
mysql> select @@profiling;
+-------------+
| @@profiling |
+-------------+
|           0 |
+-------------+
1 row in set (0.01 sec)
 
默认情况下profiling 的值为0表示MySQL SQL Profiler处于OFF状态,如果开启SQL性能分析器后,profiling 的值将为1.
 
mysql> set profiling=1;
Query OK, 0 rows affected (0.03 sec)
 
mysql> select @@profiling;
+-------------+
| @@profiling |
+-------------+
|           1 |
+-------------+
1 row in set (0.01 sec)
 
 
上面可以看到profiling已经变为1了,但是这个是session级别的,系统是不支持的。如下测试
 
退出mysql
mysql> quit
Bye
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.45-log Source distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
查看profiling的值
mysql> select @@profiling;
+-------------+
| @@profiling |
+-------------+
|           0 |
+-------------+
1 row in set (0.01 sec)
 
发现已经变为默认值0了,那如果设置系统级会如何呢?
 
mysql> set global profiling=1;
ERROR 1228 (HY000): Variable 'profiling' is a SESSION variable and can't be used with SET GLOBAL
mysql>
 
看到这里报错了。所以mysql sql profile是session级别的。
 
2. 举个例如,看如何使用
 
mysql> create table t5 as select * from t1;
ERROR 1046 (3D000): No database selected
mysql> use backup;
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> create table t5 as select * from t1;
Query OK, 2 rows affected (0.06 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
mysql> select count(*) from t5;
+----------+
| count(*) |
+----------+
|        2 |
+----------+
1 row in set (0.00 sec)
 
mysql> select count(*) from t5;
+----------+
| count(*) |
+----------+
|        2 |
+----------+
1 row in set (0.00 sec)
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • mysql-mmm
  • mysqldump命令——MySQL数据库备份还原
  • Oracle数据导入MySQL的快捷工具:MySQL Migration Toolkit
  • 简简单单储存过程——循环一个select结果集
  • MySQL数据库十大优化技巧
  • Mysql主主复制架构配置
  • Mysql安装笔记
  • MySQL Stmt预处理提高效率问题的小研究
  • Mysql的Procedure 参数为NULL问题分析
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1