oracle执行计划中filter,oracle 执行计划 access和filter的区别

These two terms in the Predicate Information section indicate when the data source is reduced. Simply, access means only retrieve those records meeting the condition and ignore others. Filter means after you already got the data, go through them all and keep those meeting the condition and throw away the others.

1 access: 直接获取那些满足条件的数据,抛弃其他不满足的数据

2 filter: 你已经有了一些数据,对这些已经有的数据应用filter,得到满足filter的数据。

很多博客论坛都有如下结论:

access表示这个谓词条件的值将会影响数据的访问路径(表or索引),而filter表示谓词条件的值并不会影响数据访问路径,只起到过滤的作用。

但是这个结论很是含糊,而且容易歧义。很多人一看显示filter 就认为oracle没有访问索引路径的选择,肯定走全表扫描进行数据择取。真的是这样吗?

可以模拟如下场景:

create table test(aa int ,bb int ) as select rownum,rownum from dba_objects;(10w数据量)

create index .... 在aa上创建索引

select count(aa) from test where aa<500 ----access,index range scan

select count(aa) from test where aa<50000 ----- filter,index fast full scan

select count(bb) from test where aa<50000 ----filter ,table full scan

select aa,bb from test where aa<500 and bb=5

1 -- filter (bb=5)

2 --access(aa<500)

当然如果bb上建立了索引,那么filter,access的位置可能就会发生变化

明显access与filter跟是否走索引还是全表扫描无关。

上面access走索引范围扫描原因在于我只扫描到aa<500的index block我就返回结果了,而走索引快速扫描是对整个index做了扫描,相当于就是对10W条aa值对应的index block都进行扫描。那么这样区别就很明显了,filter其实可以认为在数据择取的过程中可能做了一些无用功,最终抛弃自己不需要的数据来择取最终需要的数据,而access 在数据择取方面更有针对性。也就是说access只是更倾向走索引(前提是索引存在而且合理的情况下)。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值