ITeye博客

oracle索引与like条件的关系

fourfire · 2008-07-25 13:36 · db · 非技术 · Markdown

表:gzl_action_define 字段:id:主键,有索引 name:一般字段,无索引 以下是各种写法的结果 1 select t.name from gzl_action_define t where t.id ='12' 使用索引(UNIQUE SCAN) 2 select t.name from gzl_action_define t where t.id like '12%' 使用索引(RANGE SCAN) 3 select t.name from gzl_action_define t where t.id like '%12' 不使用索引(TABLE ACCESS (FULL)) 4 select t.id from gzl_action_define t where t.id like '%12' 使用索引(FAST FULL SCAN) 5 select t.name from gzl_action_define t where t.id like '%12%' 不使用索引(TABLE ACCESS (FULL)) 6 select t.id from gzl_action_define t where t.id like '%12%' 使用索引(FAST FULL SCAN) 3、5的原因不是很清楚,估计是%在前带来的问题

评论(2)

  1. #2 楼 · fourfire · 2008-07-28 12:02

    不是写了吗 http://fourfire.iteye.com/blog/219496

  2. #1 楼 · weibaojun · 2008-07-26 01:15

    怎么知道它执行的时候有没有使用索引阿

评论功能维护中,当前仅展示历史评论。