查询慢日志

tail -50 /www/server/data/mysql-slow.log

慢日志

SET timestamp=1606788283;
select * from pre_alj_log where uid=0 and 1606788261-exittime<=1200 and clientip='';
# User@Host: bbsuser[bbsuser] @ localhost [127.0.0.1]
# Thread_id: 1124014  Schema: ultrax  QC_hit: No
# Query_time: 4.964379  Lock_time: 0.000035  Rows_sent: 1  Rows_examined: 2904777
# Rows_affected: 0  Bytes_sent: 70
SET timestamp=1606788283;
select count(*) from pre_alj_log where tid=939824;
# Time: 201201 10:04:45
# User@Host: bbsuser[bbsuser] @ localhost [127.0.0.1]
# Thread_id: 1124015  Schema: ultrax  QC_hit: No
# Query_time: 3.741798  Lock_time: 0.000028  Rows_sent: 1  Rows_examined: 2904779
# Rows_affected: 0  Bytes_sent: 70
SET timestamp=1606788285;
select count(*) from pre_alj_log where tid=1066205;
# User@Host: bbsuser[bbsuser] @ localhost [127.0.0.1]
# Thread_id: 1124019  Schema: ultrax  QC_hit: No
# Query_time: 3.674660  Lock_time: 0.000030  Rows_sent: 1  Rows_examined: 2904779
# Rows_affected: 0  Bytes_sent: 70
SET timestamp=1606788285;
select count(*) from pre_alj_log where tid=1066209;
# User@Host: bbsuser[bbsuser] @ localhost [127.0.0.1]
# Thread_id: 1124018  Schema: ultrax  QC_hit: No
# Query_time: 3.715260  Lock_time: 0.000030  Rows_sent: 1  Rows_examined: 2904779
# Rows_affected: 0  Bytes_sent: 70
SET timestamp=1606788285;
select count(*) from pre_alj_log where tid=1066207;
# User@Host: bbsuser[bbsuser] @ localhost [127.0.0.1]
# Thread_id: 1124016  Schema: ultrax  QC_hit: No
# Query_time: 3.694042  Lock_time: 0.000042  Rows_sent: 1  Rows_examined: 2904779
# Rows_affected: 0  Bytes_sent: 70
SET timestamp=1606788285;
select count(*) from pre_alj_log where tid=1066206;
# Time: 201201 10:04:47
# User@Host: bbsuser[bbsuser] @ localhost [127.0.0.1]
# Thread_id: 1124010  Schema: ultrax  QC_hit: No
# Query_time: 9.982827  Lock_time: 0.000061  Rows_sent: 0  Rows_examined: 2904775
# Rows_affected: 0  Bytes_sent: 257
SET timestamp=1606788287;
select * from pre_alj_log where uid='81817' and uid!=0 and 1606788277-exittime<=1200;

处理方法

那个表太大了,查询非常消耗非常长的时间,我把那个更改了表前缀,重新新建了一个表测试速度快了很多了。