SQL语句中的ACCESS和FILTER

Prediceate(谓词):一个查询中的WHERE限制条件。

    在查看执行计划的信息中,存在两个谓词filter和access

    简单地说,执行计划如果显示是access,就表示这个谓词条件的值将会影响数据的访问路径(表还是索引),

    而filter表示谓词条件的值并不会影响数据访问路径,只起到过滤的作用。


SQL> create table echo as select * from dba_objects;

Table created.

SQL> select * from echo where object_id=1000;
SYS                            V_$BUFFER_POOL_STATISTICS
      1000                VIEW                30-JUN-05 30-JUN-05 2005-06-30:19:10:45 VALID   N N N



Execution Plan
----------------------------------------------------------
Plan hash value: 642657756

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     8 |  1416 |   160   (2)| 00:00:02 |
|*  1 |  TABLE ACCESS FULL| ECHO |     8 |  1416 |   160   (2)| 00:00:02 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("OBJECT_ID"=1000) ---无索引的情况下,只是单纯的过滤数据。

Note
-----
   - dynamic sampling used for this statement


Statistics
----------------------------------------------------------
        288  recursive calls
          0  db block gets
        804  consistent gets
        692  physical reads
          0  redo size
       1214  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

创建索引

SQL> create index echo_ind on echo(object_id);

Index created.

SQL> select * from echo where object_id=1000;
SYS                            V_$BUFFER_POOL_STATISTICS
      1000                VIEW                30-JUN-05 30-JUN-05 2005-06-30:19:10:45 VALID   N N N



Execution Plan
----------------------------------------------------------
Plan hash value: 1345159126

----------------------------------------------------------------------------------------
| Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |          |     1 |   177 |     2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| ECHO     |     1 |   177 |     2   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | ECHO_IND |     1 |       |     1   (0)| 00:00:01 |
----------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OBJECT_ID"=1000)---
谓词条件影响到数据访问的路径,选择了索引,所以用access
Note
-----
   - dynamic sampling used for this statement


Statistics
----------------------------------------------------------
          9  recursive calls
          0  db block gets
         85  consistent gets
          4  physical reads
          0  redo size
       1218  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值