日期:2014-05-16  浏览次数:21127 次

索引失效
select e.brno, getbrname(e.brno), count(e.cstm_no)
  from hs_user_info e
 where (exists (select 1
                  from hs_err_info h
                 where error_reasonc <> ''
                   and e.cstm_no = h.cstm_no) or e.check_rst = '01')
                                 
   and exists (select t.brno
                    from itp_bctl t
                   where t.full_no = '0102' and t.state = '1' and t.brno = e.brno)

 group by e.brno
这个 只有 hs_err_info这个表的索引有效
其他两个表的索引失效了
为啥

 and t.brno = e.brno 只要加上这个条件 itp_bctl的索引就会失效
------解决方案--------------------
oracle有索引时,并不一定就会走索引,如果数据量小的时候,走全表更快更省,那么oracle就不会走索引了,
还有,创建的索引并不是任何时候都有效的,<>这种where条件,会让它的索引失效!
------解决方案--------------------
不是索引失效,数据库基础CHOOSE,他会选择是否执行索引