在花1块钱,购买了那个《服务器日志分析与流量统计》这个插件, 用来分析日志和流量, 当www.wxtv.net流量巨大, 短短几天就产生了8百万条网站日志, 使用的是mysql存储日志的方式, 该插件的作者几乎没有优化过mysql存储方式(我也不知道sqlite方式有没有优化), 大几百万的日志, 查询几乎打不开, 还把整个mysql拖死。 打开mysql的慢日志查询, 发现全是统计的语句超时了。
慢日志记录:
SET timestamp=1590377705;
select website,ip,CAST(time AS CHAR) AS time,httpstatus,size,httpmothed,pageurl,shebieinfo from weblogs where website=‘www.wxtv.net‘ and time>=‘2020-05-2100:00:01‘ and time<=‘2020-05-2123:59:59‘ and shebieinfo like ‘%baidus%‘ order by time desc limit 0,100;
# Time: 200525 11:35:10
# [email protected]: wlog[wlog] ****** Id: 1230472
# Query_time: 4.893739 Lock_time: 0.000176 Rows_sent: 1 Rows_examined: 2227923
SET timestamp=1590377710;
select count(ip) from weblogs where website=‘www.wxtv.net‘ and time>=‘2020-05-2100:00:01‘ and time<&