一,查看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. 一、什么是WPF?

    一.什么是WPF? Windows Presentation Foundation(以前的代号为“Avalon”)是 Microsoft 用于 Windows 的统一显示子系统,它通过 WinFX 公 ...

  2. 【转发】构建高可伸缩性的WEB交互式系统(中)

    原文转自:http://kb.cnblogs.com/page/503953/ 在<构建高可伸缩性的WEB交互式系统>的第一篇,我们介绍了Web交互式系统中平台的可伸缩性.本文将描述模块的 ...

  3. Ztree实现带checkBox的下拉框

    UI <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ArticleMove ...

  4. JS 日历控件

    http://www.cnblogs.com/yank/archive/2008/08/14/1267746.html http://code.google.com/p/lhgcalendar/dow ...

  5. H - 放苹果

      Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Des ...

  6. matlab norm的使用

    格式:n=norm(A,p)功能:norm函数可计算几种不同类型的矩阵范数,根据p的不同可得到不同的范数 以下是Matlab中help norm 的解释 NORM Matrix or vector n ...

  7. linux的ftp使用方法

    linux下常用FTP命令 1. 连接ftp服务器 以下是在服务器为Ubuntu环境下操作: (1)首先需要安装vsftp软件,已经安装的可跳过. 1.更新软件源 #apt-get  update 2 ...

  8. 【ajax】FormData

  9. (实用篇)PHP实现队列及队列原理

    队列是一种线性表,按照先进先出的原则进行的: PHP实现队列:第一个元素作为队头,最后一个元素作为队尾 <?php /** * 队列就是这么简单 * * @link */ $array = ar ...

  10. iOS学习笔记---c语言第八天

    指针 首先将变量a的地址存放在另一个变量中,比如存放在变量b中,然后通过变量b来间接引用变量a,间接读写变量a的值.用来存放变量地址的变量,就称为"指针变量" int *p=nul ...