温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

oracle 执行计划 access和filter的区别

发布时间:2020-06-27 18:33:09 来源:网络 阅读:5641 作者:lych528 栏目:关系型数据库

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只是更倾向走索引(前提是索引存在而且合理的情况下)。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI