【提示】filter 与access 的区别

filter 与 access 的区别
filter 是过滤数据,access 是选择表的访问路径。
SQL> create table t1 (x int,y int);
表已创建。
SQL> set autotrace trace exp;
SQL> select /*+ rule */ * from t1 where x=5;
已用时间:  00: 00: 00.00
执行计划
----------------------------------------------------------
Plan hash value: 3617692013                                                    
----------------------------------                                             
| Id  | Operation         | Name |                                             
----------------------------------                                             
|   0 | SELECT STATEMENT  |      |                                             
|*  1 |  TABLE ACCESS FULL| T1   |                                             
----------------------------------                                             
Predicate Information (identified by operation id):                            
---------------------------------------------------                            
   1 - filter("X"=5) --表t1 没有建立索引,此时不可能走索引,filter起到过滤数据的作用。                                                          
Note                                                                           
-----                                                                          
   - rule based optimizer used (consider using cbo)                            
SQL> select * from t1 where x=5;
已用时间:  00: 00: 00.01
执行计划
----------------------------------------------------------   
Plan hash value: 3617692013                                                    
                                                                               
--------------------------------------------------------------------------     
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     1 |    26 |     2   (0)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL| T1   |     1 |    26 |     2   (0)| 00:00:01 |
--------------------------------------------------------------------------     
Predicate Information (identified by operation id):                            
---------------------------------------------------                            
   1 - filter("X"=5)                                                          
Note                                                                           
-----                                                                          
   - dynamic sampling used for this statement                                  
已用时间:  00: 00: 12.01
SQL> create table t1 ( x int , y int);
表已创建。
已用时间:  00: 00: 00.53
SQL> set autot trace exp
SQL> select * from t1 where x =5;
已用时间:  00: 00: 00.06
执行计划
----------------------------------------------------------                     
Plan hash value: 3617692013                                                    
--------------------------------------------------------------------------     
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |     
--------------------------------------------------------------------------     
|   0 | SELECT STATEMENT  |      |     1 |    26 |     2   (0)| 00:00:01 |     
|*  1 |  TABLE ACCESS FULL| T1   |     1 |    26 |     2   (0)| 00:00:01 |     
--------------------------------------------------------------------------     
Predicate Information (identified by operation id):                            
---------------------------------------------------                            
   1 - filter("X"=5)                                                          
Note                                                                           
-----                                                                          
   - dynamic sampling used for this statement                                  
SQL> create index idx_t on t1(x,y);
索引已创建。
SQL> select * from t1 where x =5;
执行计划
----------------------------------------------------------                     
Plan hash value: 3617692013                                                    
--------------------------------------------------------------------------     
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |     
--------------------------------------------------------------------------     
|   0 | SELECT STATEMENT  |      |     1 |    26 |     2   (0)| 00:00:01 |     
|*  1 |  TABLE ACCESS FULL| T1   |     1 |    26 |     2   (0)| 00:00:01 |     
--------------------------------------------------------------------------     
Predicate Information (identified by operation id):                            
--------------------------------------------------                            
   1 - filter("X"=5)                                                           
Note                                                                           
-----                                                                          
   - dynamic sampling used for this statement                                  

SQL> select /*+ rule */ * from t1 where x=5;
已用时间:  00: 00: 00.01
执行计划
----------------------------------------------------------                     
Plan hash value: 2296882198                                                   
----------------------------------                                             
| Id  | Operation        | Name  |                                             
----------------------------------                                             
|   0 | SELECT STATEMENT |       |                                             
|*  1 |  INDEX RANGE SCAN| IDX_T |                                             
----------------------------------                                             
Predicate Information (identified by operation id):                            
---------------------------------------------------                          
   1 - access("X"=5)  --这次谓词影响到数据的访问路径选择索引。                                           
Note                                                                           
-----                                                                          
   - rule based optimizer used (consider using cbo)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22664653/viewspace-676314/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22664653/viewspace-676314/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值