zoukankan      html  css  js  c++  java
  • [mysql] 查看mysql执行时间

    mysql的 profiling不是默认打开的

    查看profiling是否找开

    mysql> show variables like "%pro%";
    +---------------------------+-------+
    | Variable_name             | Value |
    +---------------------------+-------+
    | profiling                 | OFF   |
    | profiling_history_size    | 15    |
    | protocol_version          | 10    |
    | slave_compressed_protocol | OFF   |
    +---------------------------+-------+

    打开profiling

    mysql> set profiling=1;

    使用

    mysql> show tables;
    +----------------+
    | Tables_in_test |
    +----------------+
    | test    |
    | user           |
    +----------------+
    mysql> select * from test;
    mysql> show profiles;
    +----------+------------+------------------------+
    | Query_ID | Duration   | Query                  |
    +----------+------------+------------------------+
    |        1 | 0.00054675 | show tables            |
    |        2 | 0.00032400 | select * from test       |
    +----------+------------+------------------------+
    2 rows in set (0.00 sec)
    mysql> show profile for query 1;
    +----------------------+-----------+
    | Status               | Duration  |
    +----------------------+-----------+
    | (initialization)     | 0.000028  |
    | checking permissions | 0.000007  |
    | Opening tables       | 0.0000939 |
    | System lock          | 0.0000017 |
    | Table lock           | 0.0000055 |
    | init                 | 0.000009  |
    | optimizing           | 0.0000027 |
    | statistics           | 0.0000085 |
    | preparing            | 0.0000065 |
    | executing            | 0.000004  |
    | checking permissions | 0.000258  |
    | Sending data         | 0.000049  |
    | end                  | 0.0000037 |
    | query end            | 0.0000027 |
    | freeing items        | 0.0000307 |
    | closing tables       | 0.0000032 |
    | removing tmp table   | 0.0000275 |
    | closing tables       | 0.0000037 |
    | logging slow query   | 0.000002  |
    +----------------------+-----------+
    19 rows in set (0.00 sec)

      

  • 相关阅读:
    安装DCOS,关于docker异常引发的调查
    搭建DNS服务器-bind
    DNSmasq
    桥接以及Mercury MW54R中继
    docker异常处理
    vmware的双网卡以及Pro的注册码
    ssh免密登录
    系统原生文件MD5值获取
    mysql数据库要按当天、昨天、前七日、近三十天、季度、年查询
    dirname(__FILE__) 介绍
  • 原文地址:https://www.cnblogs.com/bluefrog/p/3512224.html
Copyright © 2011-2022 走看看