mysql调优-如何定位慢查询sql

1.业务驱动

2.测试驱动

3慢查询日志

 

慢查询日志配置

show variables like 'slow_query_log'

set global slow_query_log = on

set global slow_query_log_file = '/var/lib/mysql/gupaoedu-slow.log'

set global log_queries_not_using_indexes = on

set global long_query_time = 0.1 (秒)

慢查询日志分析

mysql调优-如何定位慢查询sql

Time :日志记录的时间

[email protected]:执行的用户及主机

Query_time:查询耗费时间

Lock_time 锁表时间

Rows_sent 发送给请求方的记录 条数

Rows_examined 语句扫描的记录条数

SET timestamp 语句执行的时间点

select .... 执行的具体语句

慢查询日志分析工具

MySQL自带的慢查询日志分析工具

mysqldumpslow -t 10 -s at /var/lib/mysql/bbb.log

mysql调优-如何定位慢查询sql

其他工具

mysqlsla

pt-query-digest

相关文章:

  • 2021-04-18
  • 2021-07-05
  • 2021-10-28
  • 2021-06-13
  • 2021-12-02
  • 2021-09-28
猜你喜欢
  • 2021-11-15
  • 2021-05-27
  • 2021-07-01
相关资源
相似解决方案