优化WAF日志查询速度

This commit is contained in:
GoEdgeLab
2021-08-22 16:20:40 +08:00
parent b3f8a7704a
commit 55fe8f5707

View File

@@ -255,6 +255,7 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx, lastRequestId string, s
} }
} else { } else {
query.Attr("remoteAddr", ip) query.Attr("remoteAddr", ip)
query.UseIndex("remoteAddr")
} }
} else { } else {
query.Where("JSON_EXTRACT(content, '$.remoteAddr')=:ip1"). query.Where("JSON_EXTRACT(content, '$.remoteAddr')=:ip1").
@@ -270,6 +271,7 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx, lastRequestId string, s
Param("host2", domain) Param("host2", domain)
} else { } else {
query.Attr("domain", domain) query.Attr("domain", domain)
query.UseIndex("domain")
} }
} else { } else {
query.Where("JSON_EXTRACT(content, '$.host')=:host1"). query.Where("JSON_EXTRACT(content, '$.host')=:host1").