【提示】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) 

相关文章
|
3天前
BurpSuite8.2 -- 查找包含id参数的URL
BurpSuite8.2 -- 查找包含id参数的URL
22 1
|
8月前
|
安全 JavaScript 前端开发
Content Security Policy 学习笔记之二:default-src 指令的使用方式
Content Security Policy 学习笔记之二:default-src 指令的使用方式
163 0
|
Shell
wandb.errors.UsageError: api_key not configured (no-tty). call wandb.login(key=[your_api_key])
wandb.errors.UsageError: api_key not configured (no-tty). call wandb.login(key=[your_api_key])
3008 0
wandb.errors.UsageError: api_key not configured (no-tty). call wandb.login(key=[your_api_key])
|
SQL JavaScript 前端开发
第三十六章 使用 CSP 进行基于标签的开发 - 使用尽可能少的#server和#call调用
第三十六章 使用 CSP 进行基于标签的开发 - 使用尽可能少的#server和#call调用
|
SQL 存储 关系型数据库
访问方法access method---单表访问方法(三十六)
访问方法access method---单表访问方法(三十六)
如何处理SAP gateway service使用过程中遇到的400 error - invalid key predicate type for guid
如何处理SAP gateway service使用过程中遇到的400 error - invalid key predicate type for guid
228 0
如何处理SAP gateway service使用过程中遇到的400 error - invalid key predicate type for guid
SAP Spartacus auth.service.ts里的user调用触发的源代码位置
SAP Spartacus auth.service.ts里的user调用触发的源代码位置
SAP Spartacus auth.service.ts里的user调用触发的源代码位置