oracle 執行計畫 access和filter的區別

來源:互聯網
上載者:User

標籤:全表掃描   format   訪問   顯示   test   做了   情境   keep   others   

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

oracle 執行計畫 access和filter的區別

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.