通过Profiles查看create语句的执行时间消耗 (转)
一,查看profiles的状态值
1,查看profiles是否已经打开了,默认是不打开的。
mysql> show profiles;
Empty set (0.02 sec)
mysql> show variables like '%pro%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| have_profiling | YES |
| profiling | OFF |
| profiling_history_size | 15 |
| protocol_version | 10 |
| proxy_user | |
| slave_compressed_protocol | OFF |
+---------------------------+-------+
6 rows in set (0.00 sec)
我查看一下profiles里面没有东西,所以公司服务器里面profile是没有打开的,我查看了一下mysql变量,果然是OFF的。
二,打开profiles,然后测试
1,开启profiles
mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)
2,check下状态值,果然已经开启了,为ON
mysql> show variables like '%pro%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| have_profiling | YES |
| profiling | ON |
| profiling_history_size | 15 |
| protocol_version | 10 |
| proxy_user | |
| slave_compressed_protocol | OFF |
+---------------------------+-------+
6 rows in set (0.00 sec)
3,测试
mysql> drop table if exists test_cpny.listed_cpny_fin_rpt_prd;
Query OK, 0 rows affected (0.08 sec)
mysql> create table test_cpny.listed_cpny_fin_rpt_prd
-> SELECT dat.*
-> FROM test.qa_cpny es
-> inner join cdp.listed_cpny_fin_rpt_prd dat
-> on (es.excel_id = dat.excel_id)
-> ;
Query OK, 60960 rows affected (30.00 sec)
Records: 60960 Duplicates: 0 Warnings: 0
mysql>
4,查看结果值:
mysql> show profiles;
+----------+------------+-----------------------------------------------------------------------------------------------------
| Query_ID | Duration | Query
+----------+------------+-----------------------------------------------------------------------------------------------------
| 1 | 0.00044300 | show variables like '%pro%'
| 2 | 0.05818800 | drop table if exists test_cpny.listed_cpny_fin_rpt_prd
| 3 | 30.0030300 | create table test_cpny.listed_cpny_fin_rpt_prd
SELECT dat.*
FROM test.qa_cpny es
inner join cdp.listed_cpny_fin_rpt_prd dat
on (es.excel_id = dat.excel_id) |
+----------+------------+-----------------------------------------------------------------------------------------------------
3 rows in set (0.00 sec)
mysql>
5,再check
mysql> show profile for query 3;
+------------------------------+----------+
| Status | Duration |
+------------------------------+----------+
| starting | 0.000072 |
| checking permissions | 0.000007 |
| checking permissions | 0.000003 |
| checking permissions | 0.000007 |
| Opening tables | 0.000161 |
| System lock | 0.000013 |
| init | 0.000006 |
| checking permissions | 0.000065 |
| creating table | 0.003520 |
| After create | 0.000089 |
| System lock | 0.000011 |
| optimizing | 0.000011 |
| statistics | 0.000016 |
| preparing | 0.000010 |
| executing | 0.000003 |
| Sending data | 29.96599 |
| Waiting for query cache lock | 0.000014 |
| Sending data | 0.010215 |
| end | 0.000016 |
| query end | 0.000004 |
| closing tables | 0.000016 |
| freeing items | 0.000042 |
| logging slow query | 0.000004 |
| cleaning up | 0.000004 |
+------------------------------+----------+
24 rows in set (0.00 sec)
看来时间消耗在| Sending data | 29.96599 |上面啊!
补充于2014-09-16
-
The number of statements for which to maintain profiling information if
profilingis enabled. The default value is 15. The maximum value is 100. Setting the value to 0 effectively disables profiling. See Section 13.7.5.32, “SHOW PROFILESSyntax”.
通过Profiles查看create语句的执行时间消耗 (转)的更多相关文章
- sql中的系统表sysobjects以及如何查看sql语句的执行时间
使用sysobjects可以快速查看数据库中表.视图.存储过程.触发器.约束等的信息. 大牛文章:http://www.cnblogs.com/atree/p/SQL-Server-sysobject ...
- SQLServer 查看SQL语句的执行时间
在MSSQL Server中通过查看SQL语句执行所用的时间,来衡量SQL语句的性能. 通过设置STATISTICS我们可以查看执行SQL时的系统情况.选项有PROFILE,IO ,TIME.介绍如下 ...
- SQL 查看SQL语句的执行时间 直接有效的方法
在MSSQL Server中通过查看SQL语句执行所用的时间,来衡量SQL语句的性能. 通过设置STATISTICS我们可以查看执行SQL时的系统情况.选项有PROFILE,IO ,TIME.介绍如下 ...
- (小技巧)Sql server查看sql语句的执行时间(转)
转自CSDN: 在写数据库sql的时候,我们往往很关心该sql语句的执行效率,如下小技巧可以帮助程序员简单快速的得到某条或某几条sql的执行时间. declare @d datetime set @d ...
- 使用Profiles分析SQL语句运行时间和消耗资源
打开profiling,默认是没开启的. mysql> set profiling=1; 运行要分析的SQL语句 mysql> select count(1) from wechat_em ...
- 查看sql语句执行的消耗
set statistics profile on set statistics io on set statistics time on go <这里写上你的语句...> go set ...
- 项目中调试SQLServer 方便的查看SQL语句的执行时间的方法
第一种方法,先记录执行前的时间,然后在记录执行Sql后的时间,然后做减法 1 第一种方法: 2 declare @begin_date datetime 3 declare @end_date dat ...
- mysql 如何查看sql语句执行时间和效率
查看执行时间 1 show profiles; 2 show variables;查看profiling 是否是on状态: 3 如果是off,则 set profiling = 1: 4 执行自己的s ...
- mysql 如何查看sql语句执行时间
查看执行时间 1 show profiles; 2 show variables;查看profiling 是否是on状态: 3 如果是off,则 set profiling = 1: 4 执行自己的s ...
随机推荐
- Extjs学习笔记(-):ComboBox联动
http://www.cnblogs.com/wumin97136/archive/2007/12/24/1012720.html http://examples.ext.net/ http://ex ...
- js中 return false
一.返回控制与函数结果, 语法为:return 表达式; 语句结束函数执行,返回调用函数,而且把表达式的值作为函数的结果 二.返回控制, 无函数结果,语法为:return; 在大多数情况下,为事件 ...
- iOS-KVC/KVO的理解
1.KVC:Key-Value Coding,直译是:键值编码.简单来讲,就是给属性设置值的:复杂来讲,根据网上的说法,KVC运用了一个isa-swizzling技术.isa-swizzling就是类 ...
- VC++编程中常用的字符串转换函数
VC++编程中经常遇到不同编码编码的字符串之间需要转换的情况,以下简单提供几个不同编码字符串之间的转换函数: ANSI 字符串和Unicode字符串之间的转换 //Convert wide char ...
- nginx源码学习资源(不断更新)
nginx源码学习是一个痛苦又快乐的过程,下面列出了一些nginx的学习资源. 首先要做的当然是下载一份nginx源码,可以从nginx官方网站下载一份最新的. 看了nginx源码,发现这是一份完全没 ...
- Gitlab. Disable user creation on welcome page
Login to your Gitlab > Admin area > settings > Features > remove the check mark "Si ...
- DB2 函数大全
DB2函数大全 函数名 函数解释 函数举例 AVG() 返回一组数值的平均值. SELECTAVG(SALARY)FROMBSEMPMS; CORR(),CORRELATION() 返回一对数值的关系 ...
- C++ Primer : 第十一章 : 关联容器之关联容器的迭代器和操作
关联容器的操作 除了和顺序容器定义的类型之外,关联容器还定义了一下几种类型: 关联容器额外的类型别名 key_type 此容器类型的关键字类型 mapped_type 每个关键字关联的类型, ...
- leetcode 150. Evaluate Reverse Polish Notation ------ java
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, ...
- 课堂所讲整理:super和转型(修改版)
创建父类: package org.hanqi.pn0120; public class Father { private String name; private int age; public S ...