使用Profiles分析SQL语句执行时间和消耗资源
2015-08-07 11:30
555 查看
打开profiling,默认是没开启的.
执行要分析的SQL语句
显示profiles表
查询结果:
查询详细信息:
结果:
mysql> set profiling=1;
执行要分析的SQL语句
mysql> select count(1) from wechat_employee,Employee;
显示profiles表
mysql> show profiles;
查询结果:
+----------+------------+-----------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+-----------------------------------------------+ | 1 | 0.00072975 | select count(1) from wechat_employee,Employee | | 2 | 0.00028450 | set profiling=1 | | 3 | 0.00324875 | select count(1) from wechat_employee,Employee | +----------+------------+-----------------------------------------------+
查询详细信息:
show profile cpu,block io for query 3;
结果:
+--------------------------------+----------+----------+------------+--------------+---------------+ | Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out | +--------------------------------+----------+----------+------------+--------------+---------------+ | starting | 0.000041 | 0.000000 | 0.000000 | 0 | 0 | | Waiting for query cache lock | 0.000073 | 0.000000 | 0.000000 | 0 | 0 | | checking query cache for query | 0.000025 | 0.000000 | 0.000000 | 0 | 0 | | checking privileges on cached | 0.000023 | 0.000000 | 0.000000 | 0 | 0 | | checking permissions | 0.000018 | 0.000000 | 0.000000 | 0 | 0 | | checking permissions | 0.000012 | 0.000000 | 0.000000 | 0 | 0 | | sending cached result to clien | 0.003009 | 0.000000 | 0.004000 | 0 | 0 | | logging slow query | 0.000032 | 0.000000 | 0.000000 | 0 | 0 | | cleaning up | 0.000018 | 0.000000 | 0.000000 | 0 | 0 | +--------------------------------+----------+----------+------------+--------------+---------------+ 9 rows in set (0.00 sec)
相关文章推荐
- ORACLE批量更新三种方法比较
- MongoDB分片集群配置
- MySql获取各种日期
- sql之left join、right join、inner join的区别
- oracle转Mysql中,varchar2(10)和number应该转换为什么类型?
- iOS 使用FMDB进行数据库操作
- centOS 7.1.1503 搭建Apache+Mariadb+PHP环境
- 怎样设置才能允许外网访问MySQL
- 5、SQL Server数据库、T-SQL
- virtualenv No module named MySQLdb
- MySQL数据库表名、列名、别名区分大小写的问题及解决
- MySQL sql-mode
- VS2012+EF6+Mysql配置心路历程
- 数据库的分类
- mysql一次添加多条记录
- 数据库学习心得
- 【MongoDB】3.0 配置文件相关介绍
- 创建mysql表分区的方法
- SQL经典入门(第5版)学习笔记
- oracle form使用commit