Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在性能方面优化这个mySQL查询?_Php_Mysql - Fatal编程技术网

Php 如何在性能方面优化这个mySQL查询?

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。解释选

如何优化follow查询

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

这个查询没有错。 如果音量较大,可能会出现性能问题。 试着在任何情况下使用。在你的情况下,我不知道是否可能。 另一个技巧是解释你的问题! 在查询之前使用explain。解释选择哈希、时间戳、计数*。。。。。。。。。
通过这种方式,您可以发现查询返回了多少个结果

你可以先找出它慢的原因。没问题,随时都可以。