zoukankan      html  css  js  c++  java
  • MySQL查找SQL耗时瓶颈 SHOW profiles

    http://blog.csdn.net/k_scott/article/details/8804384

    1、首先查看是否开启profiling功能
    [sql] view plain copy
     
    1. SHOW VARIABLES LIKE '%pro%';  

    或者

    [sql] view plain copy
     
    1. SELECT @@profiling;  


    2、开启profiling

    [sql] view plain copy
     
    1. SET profiling=1;  

    3、执行sql语句

    例如:

    [sql] view plain copy
     
    1. SELECT   
    2.   table_schema AS 'Db Name',  
    3.   ROUND( SUM( data_length + index_length ) / 1024 / 1024, 3 ) AS 'Db Size (MB)',  
    4.   ROUND( SUM( data_free ) / 1024 / 1024, 3 ) AS 'Free Space (MB)'  
    5. FROM information_schema.tables  
    6. GROUP BY table_schema ;  

    4、查看结果

    [sql] view plain copy
     
    1. SHOW profiles;  
    [sql] view plain copy
     
    1. SHOW profile ALL FOR QUERY 94;  

    94是查询ID号。

    SHOW profiles语法:

    [sql] view plain copy
     
    1. SHOW PROFILE [type [, type] … ]  
    2.     [FOR QUERY n]  
    3.     [LIMIT row_count [OFFSET offset]]  
    4.   
    5. type:  
    6.     ALL  
    7.   | BLOCK IO  
    8.   | CONTEXT SWITCHES  
    9.   | CPU  
    10.   | IPC  
    11.   | MEMORY  
    12.   | PAGE FAULTS  
    13.   | SOURCE  
    14.   | SWAPS  



     

     
     
     
  • 相关阅读:
    蓝牙遐想
    BT stack浅入了解
    集合(set)
    字典练习
    数据类型--字典
    数据类型--元组
    字符串
    深浅copy
    python---list
    三种Div高度自适应的方法
  • 原文地址:https://www.cnblogs.com/mydriverc/p/7086509.html
Copyright © 2011-2022 走看看