仔细查看了一下执行计划,问题清楚了,原sql类似如下 select * from tab where d_date>=:arg1 and d_date<=:arg2 and typeid in( 1,3..20 ) 该表分别对d_date和typeid列建了两个索引当使用select * from tab where d_date>=:arg1 and d_date<=:arg2 语句时 ,oracle选择了d_date索引,结果该索引使数据搜索范围大大降低当增加in语句后,d_date索引未被使用,而使用了typeid作为索引,结果该索引的意义不大,导致性能下降,看来索引确实不能乱建
最终把sql语句改成了 select * from tab where d_date>=:arg1 and d_date<=:arg2 and typeid+0 in( 1,3..20 )
select * from tab where d_date>=:arg1 and d_date<=:arg2 and typeid in( 1,3..20 )
该表分别对d_date和typeid列建了两个索引当使用select * from tab where d_date>=:arg1 and d_date<=:arg2 语句时 ,oracle选择了d_date索引,结果该索引使数据搜索范围大大降低当增加in语句后,d_date索引未被使用,而使用了typeid作为索引,结果该索引的意义不大,导致性能下降,看来索引确实不能乱建
select * from tab where d_date>=:arg1 and d_date<=:arg2 and typeid+0 in( 1,3..20 )