mysql5.7设置慢查询时间_mysql5.7 慢查询配置 查看sql语句执行时间

windows 下mysql5.7 慢查询配置

查看慢配置查询的

show variables like ‘%query%’;

7307411480c4151e5675c5f901d482e2.png

show variables like ‘long_query_time’ ; //可以显示当前慢查询时间

set long_query_time=1 ; //慢查询的时间默认为10秒 可以修改慢查询时间也可

mysql5.7 可以直接在配置文件my.ini 中写配置

/start*/

log_slow_admin_statements = ON

log_slow_slave_statements = ON

slow_query_log = ON //开启慢查询

slow_query_log_file = E:\MySQL-5.7.13-winx64\data\pc-PC-slow.log //设置路径

long_query_time =1 //设置慢查询时间 超过一秒的记录

/end*/

以在my.ini种配置

/********************************************************/

查看sql语句执行时间

Show variables like ‘profiling’; 查看sql语句 性能分析

看profile是否开启 5.7的

mysql> show variables like ‘%profiling%’;

+————————+——-+

| Variable_name | Value |

+————————+——-+

| have_profiling | YES |

| profiling | ON |

| profiling_history_size | 15 |

+————————+——-+

set profiling=on; 开启profile

查看执行过的sql 的执行时间

show profiles;

mysql> show profiles;

+———-+————+——————————————————————————-+

| Query_ID | Duration | Query |

+———-+————+——————————————————————————-+

| 1 | 0.00081975 | explain select * from t_log_login where id=’46702e55f23911e49d5cac162d8aadd4’ |

| 2 | 0.00436950 | select * from t_log_login where id=’46702e55f23911e49d5cac162d8aadd4’ |

+———-+————+——————————————————————————-+

查询所花费的时间 query_id=1 的语句执行时间

select sum(duration) from information_schema.profiling where query_id=1; # Query ID = 1

查看 # Query ID = 1的执行时间

mysql> show profile for query 1;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值