通过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
profiling
is 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 PROFILES
Syntax”.
通过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 ...
随机推荐
- myEclipse使用有感
一.破解 使用myeclipse 10.0版本:然后破解:(之前我使用10.7破解成功了,但是发布有问题) 二.发布注意事项 1.清理发布目录, 不要有多个项目搅和 2.js相关, 注意清理浏览器缓存 ...
- CSS 实现:文字水平垂直居中
☊ [实现要求]: <div class="demo1"> 标题1111 </div> √ [实现]: 方案一:普通布局 .demo1 { text-ali ...
- MySQL优化—工欲善其事,必先利其器之EXPLAIN(转)
最近慢慢接触MySQL,了解如何优化它也迫在眉睫了,话说工欲善其事,必先利其器.最近我就打算了解下几个优化MySQL中经常用到的工具.今天就简单介绍下EXPLAIN. 内容导航 id select_t ...
- 一直纠结中的"底层模板"含义(借鉴)
无意间看到这个解释,推荐给哪些和我一样迷惑的人!
- Sed 直接修改文件
sed最常用的用法莫过于替换文件,然而其默认的模式是直接输出在shell中 sed 's/Old/New/' My_File.txt 如果我们想要sed直接在文件中更改,只需要在sed后面添加 -i ...
- 使用使用for in 语句,并对数组中元素进行了增删操作,报错却不知怎么办?
解决方案: 在forin遍历过程中不要对遍历数据进行修改, for in 的时候如果在操作内移除会打乱 他的count 导致出错,如果要修改尽量用for循环
- Sprint第二个冲刺(第四天)
一.Sprint 计划会议: 第四次会议总结情况如下展示:昨天完成了美化按钮.增添图片的功能,今天在我们的努力下又完成了查看用户资料和底栏显示功能,由此可见我们团队的小伙伴都很厉害,也很勤奋.从燃尽图 ...
- Codeforces Round #260 (Div. 2) A B C 水 找规律(大数对小数取模) dp
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- ScrollView和ListView的冲突问题
在ScrollView添加一个ListView会导致listview控件显示不全,这是因为两个控件的滚动事件冲突导致.所以需要通过listview中的item数量去计算listview的显示高度,从而 ...
- HDU 4597 记忆化搜索
² 博弈取牌—记忆化搜索 题目描述: 有两副带有数字的牌,(数字>0)两人轮流取,取中了某张牌,自己的分数就加上牌上的数字,但只能从两端取,每人都会用最优的策略使得自己的分数最高.问A先取,他能 ...