1、建立组合索引,但查询谓词并未使用组合索引的第一列,此处有一个 INDEX SKIP SCAN
概念。
2、在包含有 null 值的 table 列上建立索引,当时使用 select count(*) from table 时不会使用
索引。
3、在索引列上使用函数时不会使用索引,如果一定要使用索引只能建立函数索引。
4、当被索引的列进行隐式的类型转换时不会使用索引。如:select * from t where
indexed_column = 5,而 indexed_column 列建立索引但类型是字符型,这时 Oracle 会产生隐
式的类型转换,转换后的语句类似于 select * from t where to_number(indexed_column) = 5,
此时不走索引的情况类似于 case3。日期转换也有类似问题,如: select * from t where
trunc(date_col) = trunc(sysdate)其中 date_col 为索引列,这样写不会走索引,可改写成
select * from t where date_col >= trunc(sysdate) and date_col < trunc(sysdate+1),此查询会走
索引。
5、并不是所有情况使用索引都会加快查询速度,full scan table 有时会更快,尤其是当查询
的数据量占整个表的比重较大时(大约为大于总量的 20%时),因为 full scan table 采用的
是多块读,当 Oracle 优化器没有选择使用索引时不要立即强制使用,要充分证明使用索引
确实查询更快时再使用强制索引。
评论0
最新资源