如何在性能方面优化此mySQL查询


How to optimize this mySQL query in terms of performance?

如何优化以下查询?

select
hash,page,timestamp, count(*) as total
from behaviour
group by hash, page
having total > 2 AND timestamp >= Now() - interval 5 minute

感谢

这个查询没有错。如果音量更大,可能会出现性能问题。尝试始终使用"WHERE CONDITIONS"。(在你的背景下,我不知道是否可能)。另一个提示是,解释您的查询!在查询之前使用"解释"。(解释选择散列、时间戳、计数(*)……..)。通过这种方式,您可以发现查询返回了多少结果。