- 最后登录
- 2014-3-8
- 在线时间
- 38 小时
- 威望
- 121
- 金钱
- 945
- 注册时间
- 2011-10-26
- 阅读权限
- 50
- 帖子
- 38
- 精华
- 1
- 积分
- 121
- UID
- 70
|
46#
发表于 2013-10-31 17:26:40
有个疑问:
根据视频中的例子:
select mactab1.*,(select sum(id2) from mactab2 where
mactab2.id=mactab1.id) s from mactab1 where mactab1.id=100
--------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2 (100)| |
| 1 | SORT AGGREGATE | | 1 | 8 | | |
| 2 | TABLE ACCESS BY INDEX ROWID| MACTAB2 | 1 | 8 | 2 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | IDX_MACTAB2 | 1 | | 1 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID | MACTAB1 | 1 | 10 | 2 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | IDX_MACTAB1 | 1 | | 1 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$2
2 - SEL$2 / MACTAB2@SEL$2
3 - SEL$2 / MACTAB2@SEL$2
4 - SEL$1 / MACTAB1@SEL$1
5 - SEL$1 / MACTAB1@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("MACTAB2"."ID"=:B1)
5 - access("MACTAB1"."ID"=100)
Column Projection Information (identified by operation id):
-----------------------------------------------------------
1 - (#keys=0) SUM("ID2")[22]
2 - "ID2"[NUMBER,22]
3 - "MACTAB2".ROWID[ROWID,10]
4 - "MACTAB1"."ID"[NUMBER,22], "MACTAB1"."C1"[VARCHAR2,50]
5 - "MACTAB1".ROWID[ROWID,10], "MACTAB1"."ID"[NUMBER,22]
按照树形图的解析过程:
1. 从顶部开始。
2. 在树中向左下移,直至到达左节点(没有子节点的节点)。首先执行此节点。
那么首先执行节点3,但是节点3的Predicate是“3 - access("MACTAB2"."ID"=:B1)”,里面是一个变量,这个变量的值是来自下面的节点4。这样岂不是应该节点5先执行才对? |
|