[英]How to optimize this mySQL query in terms of performance?
How can I optimize the follow query ?如何优化后续查询?
select
hash,page,timestamp, count(*) as total
from behaviour
group by hash, page
having total > 2 AND timestamp >= Now() - interval 5 minute
Thank you谢谢
This query it's not wrong.这个查询没有错。 Maybe with a bigger volume, you could have a problem with performance.也许在更大的音量下,您可能会遇到性能问题。 Try use "WHERE CONDITIONS" always.始终尝试使用“WHERE CONDITIONS”。 (In your context, i don't know if is possible). (在您的上下文中,我不知道是否可能)。 Another tip, is EXPLAIN on your query!另一个提示是对您的查询进行解释! Use "explain" before your query.在查询之前使用“解释”。 (explain select hash, timestamp, count(*)........). (解释选择哈希,时间戳,计数(*)........)。 In this way, you can discover how many results your query is returned.通过这种方式,您可以发现您的查询返回了多少结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.