zoukankan      html  css  js  c++  java
  • 使用Profiles分析SQL语句运行时间和消耗资源

    打开profiling,默认是没开启的.

    mysql> set profiling=1;

    运行要分析的SQL语句

    mysql> select count(1) from wechat_employee,Employee;

    显示profiles表

    mysql> show profiles;

    查询结果:

    +----------+------------+-----------------------------------------------+
    | Query_ID | Duration   | Query                                         |
    +----------+------------+-----------------------------------------------+
    |        1 | 0.00072975 | select count(1) from wechat_employee,Employee |
    |        2 | 0.00028450 | set profiling=1                               |
    |        3 | 0.00324875 | select count(1) from wechat_employee,Employee |
    +----------+------------+-----------------------------------------------+
    

    查询具体信息:

    show profile cpu,block io for query 3;
    

    结果:

    +--------------------------------+----------+----------+------------+--------------+---------------+
    | Status                         | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
    +--------------------------------+----------+----------+------------+--------------+---------------+
    | starting                       | 0.000041 | 0.000000 |   0.000000 |            0 |             0 |
    | Waiting for query cache lock   | 0.000073 | 0.000000 |   0.000000 |            0 |             0 |
    | checking query cache for query | 0.000025 | 0.000000 |   0.000000 |            0 |             0 |
    | checking privileges on cached  | 0.000023 | 0.000000 |   0.000000 |            0 |             0 |
    | checking permissions           | 0.000018 | 0.000000 |   0.000000 |            0 |             0 |
    | checking permissions           | 0.000012 | 0.000000 |   0.000000 |            0 |             0 |
    | sending cached result to clien | 0.003009 | 0.000000 |   0.004000 |            0 |             0 |
    | logging slow query             | 0.000032 | 0.000000 |   0.000000 |            0 |             0 |
    | cleaning up                    | 0.000018 | 0.000000 |   0.000000 |            0 |             0 |
    +--------------------------------+----------+----------+------------+--------------+---------------+
    9 rows in set (0.00 sec)
    
  • 相关阅读:
    作业七:用户体验设计案例分析
    作业五:需求分析
    作业四:结对编程 词频统计
    作业四:结对编程,词频统计
    作业三:词频统计
    作业2
    Github注册过程
    ArrayList的说明及简单用法
    Java类中成员变量、局部变量、静态变量的区别
    AspNetCore.SignalR的JwtBearer认证
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/7125370.html
Copyright © 2011-2022 走看看