filter and access in explain plan output

I have found that there is often confusion on exactly what these mean. The short answer is this:

The access is the where clause used to locate the rows, which are then subject to further inclusion (filtering) by the another secondary column that wasn’t the main driver in finding rows. I think the confusion arises from the fact “filter” can be a word used to restrict output, which is what a where clause does. It also appears first in the output, which I think can also be confusing.

Below shows a simple example. There is a primary key on column C, and no index on column D.

SQL> begin
  2    for i in 1..50000 loop
  3      insert into t values(i,mod(i,2));
  4    end loop;
  5  end;
  6  /

PL/SQL procedure successfully completed.

SQL> commit;

Commit complete.

SQL> explain plan for select * from t where c = 1000 and d = 0;

Explained.

SQL> select * from table(dbms_xplan.display());

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------
Plan hash value: 1303508680

------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |     1 |    26 |     1   (0)| 00:00:01 |
|*  1 |  TABLE ACCESS BY INDEX ROWID| T    |     1 |    26 |     1   (0)| 00:00:01 |
|*  2 |   INDEX UNIQUE SCAN         | T_PK |     1 |       |     0   (0)| 00:00:01 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
   1 - filter("D"=0)
   2 - access("C"=1000)

15 rows selected.

SQL>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.