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)

      

  • 相关阅读:
    SQL查询效率注意事项 2011.12.27
    MSSQL2005数据库快照(SNAPSHOT)初探
    恢复Intellij idea删除的文件
    因样式冲突引起的div消失问题
    C# 用面向对象的思想去编程
    C# Combobox联动
    C#端加载数据库,Combobox与Node控件绑定数据源demo示例
    数据库无法打开到SQL Server连接
    SQLServer2008 远程过程调用失败
    将.db文件导入SQLServer2008数据库
  • 原文地址:https://www.cnblogs.com/bluefrog/p/3512224.html
Copyright © 2011-2022 走看看