Mysql中Profiling之性能分析
来源:互联网 发布:西安淘宝设计代运营 编辑:程序博客网 时间:2024/05/01 11:18
从启动profile之后的所有查询包括错误的语句都会记录。
关闭会话或者set profiling=0 就关闭了。
# 开启 profiling
mysql> set profiling=1;
mysql> select * from user limit 1;
mysql> select count(*) from user group by sexal;
# 查看这些语句的profile
mysql> show profiles;
+--------------+----------------+--------------------------------------------------------------+
| Query_ID | Duration | Query |
+--------------+----------------+--------------------------------------------------------------+
| 1 | 0.00013200 | SELECT DATABASE() |
| 2 | 0.00044100 | select * from user limit 2 |
| 3 | 1.95544100 | select nick,count(*) from user group by online|
+--------------+----------------+--------------------------------------------------------------+
查看具体一条(Query_ID=3 这一条)语句的profiles,包括CPU和柱塞I/O的情况
mysql> show profile cpu,block io for query 3;
+----------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+----------------------+----------+----------+------------+--------------+---------------+
| starting | 0.000057 | 0.000000 | 0.000000 | 0 | 0 |
| Opening tables | 0.000014 | 0.000000 | 0.000000 | 0 | 0 |
| System lock | 0.000006 | 0.000000 | 0.000000 | 0 | 0 |
| Table lock | 0.000009 | 0.000000 | 0.000000 | 0 | 0 |
| init | 0.000021 | 0.000000 | 0.000000 | 0 | 0 |
| optimizing | 0.000006 | 0.000000 | 0.000000 | 0 | 0 |
| statistics | 0.000011 | 0.000000 | 0.000000 | 0 | 0 |
| preparing | 0.000010 | 0.000000 | 0.000000 | 0 | 0 |
| Creating tmp table | 0.000039 | 0.000000 | 0.000000 | 0 | 0 |
| executing | 0.000005 | 0.000000 | 0.000000 | 0 | 0 |
| Copying to tmp table | 1.900619 | 1.030785 | 0.197970 | 127 | 127 |
| Sorting result | 0.000015 | 0.000000 | 0.000000 | 0 | 0 |
| Sending data | 0.000015 | 0.000000 | 0.000000 | 0 | 0 |
| end | 0.000005 | 0.000000 | 0.000000 | 0 | 0 |
| removing tmp table | 0.000008 | 0.000000 | 0.000000 | 0 | 0 |
| end | 0.000005 | 0.000000 | 0.000000 | 0 | 0 |
| query end | 0.000004 | 0.000000 | 0.000000 | 0 | 0 |
| freeing items | 0.000025 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000004 | 0.000000 | 0.000000 | 0 | 0 |
| cleaning up | 0.000005 | 0.000000 | 0.000000 | 0 | 0 |
+----------------------+----------+----------+------------+--------------+---------------+
上面就获得了一条语句的CPU和Block IO消耗,对定位瓶颈很方便,其余的一些信息,可以用语句:“Show profile *** for query 3”来获取
另外附上profiling 的学习质料
- http://www.xaprb.com/blog/2006/10/12/how-to-profile-a-query-in-mysql/
- http://www.xaprb.com/blog/2006/10/15/a-case-study-in-profiling-queries-in-mysql/
- http://www.xaprb.com/blog/2006/10/17/mysql-profiling-case-study-part-2/
- http://www.mysqlperformanceblog.com/2009/01/19/profiling-mysql-stored-routines/
- http://www.mysqlperformanceblog.com/2008/05/18/wanted-better-memory-profiling-for-mysql/
- maatkit–perldoc mk-query-profiler
- http://dev.mysql.com/tech-resources/articles/pro-mysql-ch6.html
- http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html
- http://www.scribd.com/doc/2669413/DTrace-and-MySQL-Presentation
- http://forge.mysql.com/wiki/Using_DTrace_with_MySQL
- http://wikis.sun.com/display/BluePrints/Optimizing+MySQL+Database+Application+Performan
- Mysql中Profiling之性能分析
- Mysql中Profiling之性能分析
- mysql性能优化之profiling
- Mysql自带profiling性能分析工具
- Mysql自带profiling性能分析工具
- MYSQL性能分析工具 show profiling
- Python性能分析 (Profiling)
- Profiling 性能分析
- U3D性能分析 Profiling
- 程序性能分析profiling
- mysql使用Profiling分析query语句,sql语句性能优化
- 【学习笔记】Mysql中通过profiling定位query性能瓶颈
- 性能-MySQL Profiling 的使用
- MySQL优化工具之 profiling
- mysql语句性能开销检测profiling详解
- 读《MySQL性能调优与架构设计》笔记之充分利用 Explain和Profiling
- MySQL Profiling
- Mysql优化之优化工具profiling
- Objective-C iPhone起步开发的8条建议和技巧
- poj 2977 Box walking
- sed命令简单使用-D命令-结束本轮循环
- windows下实现oracle自动备份 bat
- AXURE在原型设计中的应用
- Mysql中Profiling之性能分析
- Java中范型的作用
- Struts2访问或者添加request等属性
- 一起来学Objective-C(1)——Window下开发环境安装和Hello World
- poll, select & poll—wait底层数据结构
- 一起来学Objective-C(2)——Hello World深入
- Bootargs使用
- CString
- Unix/linux解压tar命令