show profiles

mysql提供的可以用来分析当前会话语句执行资源消耗情况的命令profile.默认是关闭的。

have_profiling=YES表示当前版本支持 该功能,我们需要开启profile功能,

set profiling=1;来开启(当前会话关闭前,只需要执行一次)

执行一条SQL语句:

select *from t3;

通过 show profiles查看SQL运行结果。

show profiles;
+----------+------------+------------------------------------------+
| Query_ID | Duration   | Query                                    |
+----------+------------+------------------------------------------+
|        1 | 0.00203775 | show variables like '%profil%'           |
|        2 | 0.00026875 | SELECT DATABASE()                        |
|        3 | 0.00055675 | show databases                           |
|        4 | 0.00013675 | show tables                              |
|        5 | 0.00194650 | show global variables like '%profiling%' |
|        6 | 0.00009400 | SELECT DATABASE()                        |
|        7 | 0.00017975 | show tables                              |
|        8 | 0.00030900 | select *from t3                          |
|        9 | 0.00003700 | zzz~set profiling=1                      |
+----------+------------+------------------------------------------+
9 rows in set, 1 warning (0.00 sec)
 

Query_ID 代表运行语句的编号,8代表执行select查询语句的编号。

通过show profile for query 8查看执行查询语句的资源消耗情况;

通过show profile bkick io,cpu for query 8查看消耗CPU和磁盘I/O的情况:

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值