慢日志
1.开启慢日志
方式一
show variables like 'slow_query%';
set global slow_query_log='ON';
set global slow_query_log_file='D:\mysql-5.7.33-winx64\data\LAPTOP-JD2V280H-slow.log';
set global log-queries-not-using-indexes = 'ON';
set global long_query_time=10;
方式二
[mysqld]
slow_query_log = ON
slow_query_log_file = /home/local/mysql/data/slow.log
log-queries-not-using-indexes = on
long_query_time = 10
2.慢SQL参数
Time Id Command Argument
use homepensioncloud;
SET timestamp=1647854019;
SELECT * from sys_user;
time: 记录日志的时间
User@Host: 执行的用户及主机
Query_time: 执行的时间
Lock_time: 锁表时间
Rows_sent: 发送给请求放的记录数,结果数量
Rows_examined: 语句扫描的记录条数
SET timestamp: 语句执行的时间点
select……: 执行的具体的SQL语句