select record_minute, max(query_per_second),domain_name,query_per_second,delay from top_normal_domain_minute where record_minute between unix_timestamp('2009-11-03 13:31:29') and unix_timestamp('2009-11-12 13:31:32') group by domain_name order by max(query_per_second) desc limit 0,10; 大家请看,这条sql语句的语义是,查询数据库表中某时间段内,查询量(wyery_per_second)最多的域名(排在前10的)。 但是执行这条sql语句的时候却发现速度异常得慢,怎么优化它。我的qq:346985049,一直在,如果有高手看到的话,请帮帮我这个要怎么解决?有没有人可以帮我 索引情况、EXPLAIN SQL语句,贴记录及要求结果出来看看 这个东西不是一言两语能说得清楚的,你可以参考下下面这个找点启发吧: http://topic.csdn.net/u/20091031/18/f86637e7-06be-403c-b6b8-56904920751b.html?59522 他那里面的方法也还是有问题,因为上一分钟和下一分钟统计到的域名可能会有相同的,所以我才group by domain_name 的。。。。。就算设计一个汇总表,效率也不会快的 创建 基于 record_minute 的索引
create index idx_top_normal_domain_minute_1 on top_normal_domain_minute(record_minute);
做优化之前你需要查看
show index from top_normal_domain_minute; explain select record_minute, max(query_per_second)
我以前安装了一次,后来卸载了,现在再安装的时候,提示错误:Error 1305.Error reading from file C:DOCUME~1\LOCALS~1\Temp\mysql_server.msi.Verify that the file exists and that you can access it. 可是我找 ......