论坛首页 入门讨论版 其他综合

oracle索引与like条件的关系

浏览 111 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2008-07-25
表: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的原因不是很清楚,估计是%在前带来的问题
   
时间:2008-07-26
怎么知道它执行的时候有没有使用索引阿
   
0 请登录后投票
时间:2008-07-28
不是写了吗
http://fourfire.javaeye.com/blog/219496
   
0 请登录后投票
论坛首页 入门讨论版 其他综合

跳转论坛:
JavaEye推荐