Php 如何在性能方面优化这个mySQL查询?
如何优化follow查询Php 如何在性能方面优化这个mySQL查询?,php,mysql,Php,Mysql,如何优化follow查询 select hash,page,timestamp, count(*) as total from behaviour group by hash, page having total > 2 AND timestamp >= Now() - interval 5 minute 谢谢这个查询没有错。 如果音量较大,可能会出现性能问题。 试着在任何情况下使用。在你的情况下,我不知道是否可能。 另一个技巧是解释你的问题! 在查询之前使用explain。解释选
select
hash,page,timestamp, count(*) as total
from behaviour
group by hash, page
having total > 2 AND timestamp >= Now() - interval 5 minute
谢谢这个查询没有错。
如果音量较大,可能会出现性能问题。
试着在任何情况下使用。在你的情况下,我不知道是否可能。
另一个技巧是解释你的问题!
在查询之前使用explain。解释选择哈希、时间戳、计数*。。。。。。。。。
通过这种方式,您可以发现查询返回了多少个结果 你可以先找出它慢的原因。没问题,随时都可以。