+ -
当前位置:首页 → 问答吧 → 大数据表优化查询方式

大数据表优化查询方式

时间:2011-09-06

来源:互联网

我有一张LOG表每天的数据可以达到200w左右,目前已经又2000W的数据,表中有5个字段id data point_id node_log_id create_time 
主键是ID 我的查询 类似这样 
select pl.id,pl.data,pl.node_log_id,pl.create_time from tbl_zb_point_log as pl where create_time >= '2011-09-05 19:56:50' and create_time <= '2011-09-05 20:56:50' and pl.point_id = 300 order by create_time ASC limit 1;

其中create_time >= 和 <= 的区间可能是一个小时 也可以能是1天 甚至一个月。


我已经在 create_time point_id 
建立单个索引,而且我试了 建组合索引的效果 不好, 不知道是我建错了还是怎么的 ?  

服务器是长期累月运行的,这个查询语句基本一天要查询一次,然后一个月查询一次,还有就是用户可能会根据自己需要随时查询一次。

请问我这个表应该怎么设计 是一天存一张表?

还有我的语句应该怎么优化?

小弟在这里谢谢各位大大了!!

作者: counter198   发布时间: 2011-09-06

create index xx x on tbl_zb_point_log (point_id, create_time)

作者: ACMAIN_CHM   发布时间: 2011-09-06

order by id ASC limit 1;

作者: rucypli   发布时间: 2011-09-06