一,查看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

通过Profiles查看create语句的执行时间消耗 (转)的更多相关文章

  1. sql中的系统表sysobjects以及如何查看sql语句的执行时间

    使用sysobjects可以快速查看数据库中表.视图.存储过程.触发器.约束等的信息. 大牛文章:http://www.cnblogs.com/atree/p/SQL-Server-sysobject ...

  2. SQLServer 查看SQL语句的执行时间

    在MSSQL Server中通过查看SQL语句执行所用的时间,来衡量SQL语句的性能. 通过设置STATISTICS我们可以查看执行SQL时的系统情况.选项有PROFILE,IO ,TIME.介绍如下 ...

  3. SQL 查看SQL语句的执行时间 直接有效的方法

    在MSSQL Server中通过查看SQL语句执行所用的时间,来衡量SQL语句的性能. 通过设置STATISTICS我们可以查看执行SQL时的系统情况.选项有PROFILE,IO ,TIME.介绍如下 ...

  4. (小技巧)Sql server查看sql语句的执行时间(转)

    转自CSDN: 在写数据库sql的时候,我们往往很关心该sql语句的执行效率,如下小技巧可以帮助程序员简单快速的得到某条或某几条sql的执行时间. declare @d datetime set @d ...

  5. 使用Profiles分析SQL语句运行时间和消耗资源

    打开profiling,默认是没开启的. mysql> set profiling=1; 运行要分析的SQL语句 mysql> select count(1) from wechat_em ...

  6. 查看sql语句执行的消耗

    set statistics profile on set statistics io on set statistics time on go <这里写上你的语句...> go set ...

  7. 项目中调试SQLServer 方便的查看SQL语句的执行时间的方法

    第一种方法,先记录执行前的时间,然后在记录执行Sql后的时间,然后做减法 1 第一种方法: 2 declare @begin_date datetime 3 declare @end_date dat ...

  8. mysql 如何查看sql语句执行时间和效率

    查看执行时间 1 show profiles; 2 show variables;查看profiling 是否是on状态: 3 如果是off,则 set profiling = 1: 4 执行自己的s ...

  9. mysql 如何查看sql语句执行时间

    查看执行时间 1 show profiles; 2 show variables;查看profiling 是否是on状态: 3 如果是off,则 set profiling = 1: 4 执行自己的s ...

随机推荐

  1. Notepad++ 编译 pascal

    一.设置——>首选项 添加pas 二.运行,在输入框中填入命令: cmd /k cd /d "$(CURRENT_DIRECTORY)" &fpc -g $(FILE ...

  2. Unity3D ShaderLab Use Properties

    在上一篇,学会了怎么使用ShaderLab 语法:Properties,这一次,我们将会使用属性值点亮材质球. 1:Delete>sampler2D _MainTex; 2:1行位置Add> ...

  3. dat文件中如何编写DOS的多行命令

    dat文件中如何编写DOS的多行命令 2012-10-15 11:29 四海柔情108 分享到:   2012-10-16 23:36 提问者采纳   你问的应该是BAT文件吧?BAT是DOS命令的批 ...

  4. 转载: SQL Server中的索引

    http://www.blogjava.net/wangdetian168/archive/2011/03/07/347192.html 1 SQL Server中的索引 索引是与表或视图关联的磁盘上 ...

  5. LeetCode Majority Element(简单题)

    题意: 给一个数组,其中有一个元素的出现次数已经超过数组的一半大小,请找出这个元素? 思路: 可以扫一遍数组,将这个出现次数过多的元素抵消其他的元素,最后必定留下1个以上的元素,就是它自己了. pyt ...

  6. LeetCode Implement Queue using Stacks (数据结构)

    题意: 用栈来实现队列. 思路: 一个栈是不够的,至少要两个. (1)插入.永远只插入到stack1中(插到栈顶). (2)弹出.如果stack2不为空,直接弹出stack2的栈顶,否则,将stack ...

  7. button 浏览器兼容问题

    ie8和360出现的问题 应该加上type属性

  8. Open vSwitch FAQ (三)

    Quality of Service (QoS) Q: How do I configure Quality of Service (QoS)? A: Suppose that you want to ...

  9. (实用篇)PHP不用递归遍历目录下所有文件的代码

    <?php /** * PHP 非递归实现查询该目录下所有文件 * @param unknown $dir * @return multitype:|multitype:string */ fu ...

  10. Sed简单入门实例

    1. Sed简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后 ...