oracle 查询不走索引的范例分析

like 后%位置不走索引问题

create table t2 as select * from dba_objects;——创建表
create index idx_t2_name on t2(object_name);——创建索引
set autotrace on ——开启执行计划跟踪
select * from t2 where object_name like 'DE%';——走索引
select * from t2 where object_name like '%DE';——不走索引

查询字段类型与表字段类型不一致导致隐式转换,不走索引问题

create table t3(id varchar2(10),name varchar2(10));——创建表t3
insert into t3 select * from dba_objects;——插入数据
commit; ——提交
create index idx_t3_id on t3(id);创建id索引
set autotrace on——开启执行计划自动跟踪
select * from t3 where id=7000;——不走索引,会出现隐式转换,filter(TO_NUMBER("ID")=7000)
select * from t3 where id='7000';——走索引,cost大大提升

另:不要用select '*' from........写select 星号时,oracle会查询数据字典再转换成具体的列名,增加oracle的开销,建议写具体字段名称
附:查询表的索引信息
select INDEX_NAME,INDEX_TYPE,TABLE_OWNER,TABLE_NAME,TABLESPACE_NAME from user_indexes where table_name='T1';

相关文章

这篇文章主要介绍“hive和mysql的区别是什么”,在日常操作中...
这篇“MySQL数据库如何改名”文章的知识点大部分人都不太理解...
这篇文章主要介绍“mysql版本查询命令是什么”的相关知识,小...
本篇内容介绍了“mysql怎么修改字段的内容”的有关知识,在实...
这篇文章主要讲解了“mysql怎么删除unique约束”,文中的讲解...
今天小编给大家分享一下mysql怎么查询不为空的字段的相关知识...