有个字段stu_id,并为它建立了索引
在select查询语句中
where子句,索引字段要放在第一个,如:where stu_id=1 and deleted<>2 而不是where  deleted<>2 and stu_id=1 
听说只有这样才会走索引,这是为什么?

解决方案 »

  1.   

    哪里有这种事情的,这么傻的话,oracle老早被抛弃了你试一下就可以了你的这个查询,索引里要包含两个字段才行create index idx_id on t(stu_id, deleted);dbms_stats.gather_table_stats(user, 'TABLE_NAME', method_opt=>'for all indexed columns', cascade=>true);然后你做测试吧
      

  2.   


    这里如果没有走索引的话,不是因为你说的这个原因,而是因为oracle的优化器决策出,走fts比索引的cost更小,这样才选择做了fts。