1、首先查看是否开启profiling功能

 
  1. SHOW VARIABLES LIKE '%pro%';  

 

或者

 
  1. SELECT @@profiling;  

 


2、开启profiling

 
  1. SET profiling=1;  

 

3、执行sql语句

 

例如:

 
  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、查看结果

 
  1. SHOW profiles;  
 
  1. SHOW profile ALL FOR QUERY 94;  

 

94是查询ID号。

 

SHOW profiles语法:

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

 

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2021-10-24
  • 2021-12-16
  • 2021-09-03
  • 2021-09-23
  • 2022-03-08
  • 2022-12-23
猜你喜欢
  • 2022-01-31
  • 2021-06-18
  • 2021-11-09
  • 2021-08-17
  • 2022-12-23
  • 2022-01-17
相关资源
相似解决方案