ITeye博客

Oracle坑不间断更新

kfc_davy · 2013-04-07 19:11 · oracle · 数据库 · Markdown

jdbc date 不走索引 jdbc中

select * from tba t where t.createtime >?

实际上不走索引(如果createtime是date类型的话),传说会转换为timestamp,对于此类需要改成,

select * from tba t  where t.createtime>to_date(?,'yyyy-mm-dd')

or 不走索引

select * from tba t where t.a in (select xxx from xxx) or t.a=b

实际上不走索引 对于此类需要改成,


select * from tba t1 where t.a in (select xxx from xxx) 
union
select * from tba t2 where t.2a = 2

小集合和大集合关联尽量走nestedloop 接上,使用union以后和另外一张表的ROWID关联,出现这种情况

cost 1 cardinality 150000

接下去的表关联直接采用了HASH JOIN; 如果前面说的不用union关联的话,ROWID关联的结果

cost 1 cardinality 1

因此小表A和大表B,关联字段有索引,那么强制走NESTED LOOP,设置

/*+ordered use_nl(b)*/

ORACLE 中 为什么使用ROWID快 在8i以前rowid由file#+block#+row#组成,占用6个bytes的空间,10 bit 的 file# ,22 bit 的 block# ,16 bit 的 row#。 其中oracle 的dba(data block address)是32 bits的,包括10 bit 的 file# 和 22 bit 的block# 详情 http://www.itpub.net/thread-653576-1-1.html

评论(0)

暂无评论。

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