当前位置: 动力学知识库 > 问答 > 编程问答 >

php - 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. (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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: