zoukankan      html  css  js  c++  java
  • mysql sql语句执行时间查询

    第一种:show profiles 之类的语句来查看

    1.查一下profile是不是打开了,默认是不打开的。

    mysql> show profiles; 
    Empty set (0.02 sec) 
    mysql> show variables like "%pro%"; 
    +---------------------------+-------+ 
    | Variable_name | Value | 
    +---------------------------+-------+ 
    | profiling | OFF | 
    | profiling_history_size | 15 | 
    | protocol_version | 10 | 
    | slave_compressed_protocol | OFF | 
    +---------------------------+-------+ 
    4 rows in set (0.00 sec)

    我查看一下profiles里面没有东西,所以公司的电脑里面profile是没有打开的,我查看了一下mysql变量,果然是OFF的。

    2.开启profile

    mysql> set profiling=1;
    Query OK, 0 rows affected (0.00 sec)

    eg:

    mysql> select * from test_1;
    mysql> show profiles;
    +----------+------------+----------------------+
    | Query_ID | Duration   | Query                |
    +----------+------------+----------------------+
    |        1 | 0.84718100 | select * from test_1 |
    +----------+------------+----------------------+
    1 row in set (0.00 sec)

    第二种:(通过时间差查看)

    delimiter // set @d=now();
    select * from comment;
    select timestampdiff(second,@d,now());
    delimiter ;
    
    
    Query OK, 0 rows affected (1 min 55.58 sec)
    
    
    +----------------------------------+
    | timestampdiff(second, @d, now()) |
    +----------------------------------+
    |                                2 |
    +----------------------------------+
    1 row in set (1 min 55.58 sec) 
  • 相关阅读:
    docker 基本概念
    6_State 游戏开发中使用状态机
    5_Singleton 游戏开发中的单例模式
    4_Prototype 原型
    3_observer
    2_flyweight, 轻量化模式
    1_Command 游戏开发命令模式
    CentOS7 Failed to start LSB: Bring up/down解决方法
    CentOS 7 中firewall-cmd命令
    CentOS查询端口占用和清除端口占用的程序
  • 原文地址:https://www.cnblogs.com/feng18/p/5457470.html
Copyright © 2011-2022 走看看