Oracle 执行计划中access 和 filter的区别
答案:1 悬赏:10 手机版
解决时间 2021-01-30 17:53
- 提问者网友:兔牙战士
- 2021-01-29 17:32
Oracle 执行计划中access 和 filter的区别
最佳答案
- 五星知识达人网友:鱼忧
- 2021-01-29 18:21
access就把数据从磁盘读到内存里都是业务所需要的数据(一般通过索引),
filter就把数据从磁盘读到内存后,还要去掉不符合where条件的数据(即读取了很多不需要的数据,做了部分无用功,比如全表扫描)
举个例子:
select * from king where id=1;(id字段上有索引时候,oracle)
执行计划:
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECt STATEMENT | | 1 | 25 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| KING | 1 | 25 | 4 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_ID | 1 | | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"=1)
-----------此时就是access
-------------------------------------------------------------------------------------
如果id上没有索引:
select * from king where id=1;
执行计划:
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 25233 (2)| 00:05:03 |
|* 1 | TABLE ACCESS FULL| KING | 1 | 25 | 25233 (2)| 00:05:03 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("ID"=1)
--------------------------------------------------------------------------------------------------------------------
filter就把数据从磁盘读到内存后,还要去掉不符合where条件的数据(即读取了很多不需要的数据,做了部分无用功,比如全表扫描)
举个例子:
select * from king where id=1;(id字段上有索引时候,oracle)
执行计划:
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECt STATEMENT | | 1 | 25 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| KING | 1 | 25 | 4 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_ID | 1 | | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"=1)
-----------此时就是access
-------------------------------------------------------------------------------------
如果id上没有索引:
select * from king where id=1;
执行计划:
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 25233 (2)| 00:05:03 |
|* 1 | TABLE ACCESS FULL| KING | 1 | 25 | 25233 (2)| 00:05:03 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("ID"=1)
--------------------------------------------------------------------------------------------------------------------
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯