首先对CONSUME_DATE建立索引:
create index idx_consume_date
on consume (consume_date);
其次,修改查询的SQL,不要对字段进行函数操作:
select * from consume
where consume_date between to_date('20010101','yyyymmdd')
and to_date('20011231','yyyymmdd');
create index idx_consume_date
on consume (consume_date);
其次,修改查询的SQL,不要对字段进行函数操作:
select * from consume
where consume_date between to_date('20010101','yyyymmdd')
and to_date('20011231','yyyymmdd');
使用BETWEEN好象比较慢,不如直接进行比较:
select * from consume
where consume_date >= to_date('20010101','yyyymmdd') and
consume_date <= to_date('20011231','yyyymmdd');
恭喜升红星了!好像BETWEEN的算法和使用>= + <=是一模一样的,以前的教科书上是这么说的.难道改了吗?