MySQL Query Profiler(性能分析工具)的使用方法
2017-11-06 16:41
681 查看
转自:http://blog.csdn.net/zhuizhuziwo/article/details/6896842
MySQL 5.0.37版本加入了
MySQL Query Profiler 数据库性能分析工具。
简单的实例
初始化:
mysql> set profiling=1;
Query OK, 0 rows affected (0.04 sec)
mysql> show profiles;
Empty set (0.00 sec)
查询语句:
mysql> SELECT COUNT(nickname),
gender FROM users GROUP BY gender;
+-----------------+--------+
| COUNT(nickname) | gender |
+-----------------+--------+
| 106773 | 0 |
| 106462 | 1 |
+-----------------+--------+
2 rows in set (0.88 sec)
查看分析列表:
mysql> show profiles\G;
+----------+------------+-----------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+-----------------------------------------------------------+
| 1 | 0.88324700 | SELECT COUNT(nickname), gender FROM users GROUP BY gender |
+----------+------------+-----------------------------------------------------------+
1 row in set (0.03 sec)
查看sql语句分析1:
mysql> show profile for query 1;
+----------------------+-----------+
| Status | Duration |
+----------------------+-----------+
| (initialization) | 0.0000699 |
| Opening tables | 0.000039 |
| System lock | 0.000008 |
| Table lock | 0.000014 |
| init | 0.000043 |
| optimizing | 0.000396 |
| statistics | 0.000024 |
| preparing | 0.000079 |
| Creating tmp table | 0.000118 |
| executing | 0.000008 |
| Copying to tmp table | 0.871251 |
| Sorting result | 0.000063 |
| Sending data | 0.009601 |
| end | 0.000017 |
| removing tmp table | 0.000028 |
| end | 0.000009 |
| query end | 0.000006 |
| freeing items | 0.000015 |
| closing tables | 0.001449 |
| logging slow query | 0.000009 |
+----------------------+-----------+
20 rows in set (0.02 sec)
只查看cpu和io:
mysql>show profile cpu,block io for query 1;
+----------------------+-----------+-----------+------------+
| Status | Duration | CPU_user | CPU_system |
+----------------------+-----------+-----------+------------+
| (initialization) | 0.0000699 | 0 | 0 |
| Opening tables | 0.000039 | 0 | 0 |
| System lock | 0.000008 | 0 | 0 |
| Table lock | 0.000014 | 0 | 0 |
| init | 0.000043 | 0 | 0.001 |
| optimizing | 0.000396 | 0 | 0 |
| statistics | 0.000024 | 0 | 0 |
| preparing | 0.000079 | 0 | 0 |
| Creating tmp table | 0.000118 | 0 | 0 |
| executing | 0.000008 | 0 | 0 |
| Copying to tmp table | 0.871251 | 0.59391 | 0.253961 |
| Sorting result | 0.000063 | 0 | 0 |
| Sending data | 0.009601 | 0.001 | 0.003 |
| end | 0.000017 | 0 | 0 |
| removing tmp table | 0.000028 | 0 | 0 |
| end | 0.000009 | 0 | 0 |
| query end | 0.000006 | 0 | 0 |
| freeing items | 0.000015 | 0 | 0 |
| closing tables | 0.001449 | 0.0009990 | 0.001 |
| logging slow query | 0.000009 | 0 | 0 |
+----------------------+-----------+-----------+------------+
20 rows in set (0.00 sec)
清零:
mysql> set profiling=0;
Query OK, 0 rows affected (0.00 sec)
MySQL 5.0.37版本加入了
MySQL Query Profiler 数据库性能分析工具。
简单的实例
初始化:
mysql> set profiling=1;
Query OK, 0 rows affected (0.04 sec)
mysql> show profiles;
Empty set (0.00 sec)
查询语句:
mysql> SELECT COUNT(nickname),
gender FROM users GROUP BY gender;
+-----------------+--------+
| COUNT(nickname) | gender |
+-----------------+--------+
| 106773 | 0 |
| 106462 | 1 |
+-----------------+--------+
2 rows in set (0.88 sec)
查看分析列表:
mysql> show profiles\G;
+----------+------------+-----------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+-----------------------------------------------------------+
| 1 | 0.88324700 | SELECT COUNT(nickname), gender FROM users GROUP BY gender |
+----------+------------+-----------------------------------------------------------+
1 row in set (0.03 sec)
查看sql语句分析1:
mysql> show profile for query 1;
+----------------------+-----------+
| Status | Duration |
+----------------------+-----------+
| (initialization) | 0.0000699 |
| Opening tables | 0.000039 |
| System lock | 0.000008 |
| Table lock | 0.000014 |
| init | 0.000043 |
| optimizing | 0.000396 |
| statistics | 0.000024 |
| preparing | 0.000079 |
| Creating tmp table | 0.000118 |
| executing | 0.000008 |
| Copying to tmp table | 0.871251 |
| Sorting result | 0.000063 |
| Sending data | 0.009601 |
| end | 0.000017 |
| removing tmp table | 0.000028 |
| end | 0.000009 |
| query end | 0.000006 |
| freeing items | 0.000015 |
| closing tables | 0.001449 |
| logging slow query | 0.000009 |
+----------------------+-----------+
20 rows in set (0.02 sec)
只查看cpu和io:
mysql>show profile cpu,block io for query 1;
+----------------------+-----------+-----------+------------+
| Status | Duration | CPU_user | CPU_system |
+----------------------+-----------+-----------+------------+
| (initialization) | 0.0000699 | 0 | 0 |
| Opening tables | 0.000039 | 0 | 0 |
| System lock | 0.000008 | 0 | 0 |
| Table lock | 0.000014 | 0 | 0 |
| init | 0.000043 | 0 | 0.001 |
| optimizing | 0.000396 | 0 | 0 |
| statistics | 0.000024 | 0 | 0 |
| preparing | 0.000079 | 0 | 0 |
| Creating tmp table | 0.000118 | 0 | 0 |
| executing | 0.000008 | 0 | 0 |
| Copying to tmp table | 0.871251 | 0.59391 | 0.253961 |
| Sorting result | 0.000063 | 0 | 0 |
| Sending data | 0.009601 | 0.001 | 0.003 |
| end | 0.000017 | 0 | 0 |
| removing tmp table | 0.000028 | 0 | 0 |
| end | 0.000009 | 0 | 0 |
| query end | 0.000006 | 0 | 0 |
| freeing items | 0.000015 | 0 | 0 |
| closing tables | 0.001449 | 0.0009990 | 0.001 |
| logging slow query | 0.000009 | 0 | 0 |
+----------------------+-----------+-----------+------------+
20 rows in set (0.00 sec)
清零:
mysql> set profiling=0;
Query OK, 0 rows affected (0.00 sec)
相关文章推荐
- Sql2005性能工具(SQL Server Profiler和数据库引擎优化顾问)使用方法详解
- [MySQL 工具] pt-query-digest使用出错问题分析Can't locate Time/HiRes.pm in @INC
- [Sql2005笔记] Sql2005性能工具(SQL Server Profiler和数据库引擎优化顾问)使用方法详解
- mysql性能监控工具:mycheckpoint的使用方法
- SQL Server 性能工具(SQL Server Profiler和数据库引擎优化顾问)使用方法详解
- Mysql自带profiling性能分析工具使用分享
- MySQL结合使用数据库分析工具SchemaSpy的方法
- 使用TraceView性能分析工具的方法
- MySQL性能分析工具profile使用教程
- 自带的性能分析调试工具TraceView使用方法
- MySQL性能分析工具profile的使用(1)
- Sql2005性能工具(SQL Server Profiler和数据库引擎优化顾问)使用方法详解
- MySQL性能分析工具profile的使用(2)
- MySQL结合使用数据库分析工具SchemaSpy的方法
- Java性能分析工具Profiler性能分析方法:离线剖析和触发器
- [MySQL优化] -- 如何使用SQL Profiler 性能分析器
- mysql 慢查询分析工具:pt-query-digest 在mac 上的安装使用
- MYSQL自带工具Query Profiler使用
- MySQL性能分析工具profile使用教程
- mysqlsla慢查询分析工具安装使用方法 - ttlsa教程系列之mysql