首页 > 数据库技术 > 详细

mysql查找sql耗时瓶颈 show profiles

时间:2015-02-24 18:34:19      阅读:328      评论:0      收藏:0      [点我收藏+]

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

SHOW VARIABLES LIKE %pro%; 

或者

SELECT @@profiling; 

2、开启profiling

SET profiling=1; 

3、执行sql语句
例如:

SELECT   
  table_schema AS Db Name,  
  ROUND( SUM( data_length + index_length ) / 1024 / 1024, 3 ) AS Db Size (MB),  
  ROUND( SUM( data_free ) / 1024 / 1024, 3 ) AS Free Space (MB)  
FROM information_schema.tables  
GROUP BY table_schema ;  

4、查看结果

SHOW profiles;  
SHOW profile ALL FOR QUERY 94;  
94是查询ID号。
SHOW profiles语法:
SHOW PROFILE [type [, type] … ]  
    [FOR QUERY n]  
    [LIMIT row_count [OFFSET offset]]  
type:  
    ALL  
  | BLOCK IO  
  | CONTEXT SWITCHES  
  | CPU  
  | IPC  
  | MEMORY  
  | PAGE FAULTS  
  | SOURCE  
  | SWAPS  

 本文转自http://blog.csdn.net/k_scott/article/details/8804384

mysql查找sql耗时瓶颈 show profiles

原文:http://www.cnblogs.com/chenqionghe/p/4298813.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!