|
针对zerg的问题,有个很有趣的结果:
如果你select t1.*,那么t3 t1会先做hash_aj,然后再t2.
如果你select t2.*, 那么t3 t2会先做hash_aj,然后再t1.
select *
from t1, t2
where t1.object_id = t2.object_id
and t1.object_id is not null
and t1.object_id not in (select t3.object_id
from t3
where t3.object_id is not null
group by object_id, object_name
having count(*) > 0);
Plan hash value: 4008314795
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 34527 | 5833K| | 670 (4)| 00:00:07 |
|* 1 | HASH JOIN RIGHT ANTI | | 34527 | 5833K| | 670 (4)| 00:00:07 |
| 2 | VIEW | VW_NSO_1 | 1818 | 23634 | | 131 (7)| 00:00:02 |
|* 3 | FILTER | | | | | | |
| 4 | HASH GROUP BY | | 1818 | 36360 | | 131 (7)| 00:00:02 |
|* 5 | TABLE ACCESS FULL| T3 | 36347 | 709K| | 125 (2)| 00:00:02 |
|* 6 | HASH JOIN | | 36345 | 5678K| 3272K| 537 (3)| 00:00:06 |
| 7 | TABLE ACCESS FULL | T2 | 36347 | 2839K| | 127 (4)| 00:00:02 |
|* 8 | TABLE ACCESS FULL | T1 | 36346 | 2839K| | 127 (4)| 00:00:02 |
------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."OBJECT_ID"="$nso_col_1")
3 - filter(COUNT(*)>0)
5 - filter("T3"."OBJECT_ID" IS NOT NULL)
6 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
8 - filter("T1"."OBJECT_ID" IS NOT NULL)
select t1.*
from t1, t2
where t1.object_id = t2.object_id
and t1.object_id is not null
and t1.object_id not in (select t3.object_id
from t3
where t3.object_id is not null
group by object_id, object_name
having count(*) > 0);
Plan hash value: 3043464937
-----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 34527 | 3270K| 387 (5)| 00:00:04 |
|* 1 | HASH JOIN | | 34527 | 3270K| 387 (5)| 00:00:04 |
| 2 | TABLE ACCESS FULL | T2 | 36347 | 141K| 125 (2)| 00:00:02 |
|* 3 | HASH JOIN RIGHT ANTI | | 34528 | 3135K| 259 (6)| 00:00:03 |
| 4 | VIEW | VW_NSO_1 | 1818 | 23634 | 131 (7)| 00:00:02 |
|* 5 | FILTER | | | | | |
| 6 | HASH GROUP BY | | 1818 | 36360 | 131 (7)| 00:00:02 |
|* 7 | TABLE ACCESS FULL| T3 | 36347 | 709K| 125 (2)| 00:00:02 |
|* 8 | TABLE ACCESS FULL | T1 | 36346 | 2839K| 127 (4)| 00:00:02 |
-----------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
3 - access("T1"."OBJECT_ID"="$nso_col_1")
5 - filter(COUNT(*)>0)
7 - filter("T3"."OBJECT_ID" IS NOT NULL)
8 - filter("T1"."OBJECT_ID" IS NOT NULL)
select t2.*
from t1, t2
where t1.object_id = t2.object_id
and t1.object_id is not null
and t1.object_id not in (select t3.object_id
from t3
where t3.object_id is not null
group by object_id, object_name
having count(*) > 0);
Plan hash value: 523046018
-----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 34527 | 3270K| 387 (5)| 00:00:04 |
|* 1 | HASH JOIN | | 34527 | 3270K| 387 (5)| 00:00:04 |
|* 2 | HASH JOIN RIGHT ANTI | | 34528 | 573K| 258 (5)| 00:00:03 |
| 3 | VIEW | VW_NSO_1 | 1818 | 23634 | 131 (7)| 00:00:02 |
|* 4 | FILTER | | | | | |
| 5 | HASH GROUP BY | | 1818 | 36360 | 131 (7)| 00:00:02 |
|* 6 | TABLE ACCESS FULL| T3 | 36347 | 709K| 125 (2)| 00:00:02 |
|* 7 | TABLE ACCESS FULL | T1 | 36346 | 141K| 125 (2)| 00:00:02 |
| 8 | TABLE ACCESS FULL | T2 | 36347 | 2839K| 127 (4)| 00:00:02 |
-----------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
2 - access("T1"."OBJECT_ID"="$nso_col_1")
4 - filter(COUNT(*)>0)
6 - filter("T3"."OBJECT_ID" IS NOT NULL)
7 - filter("T1"."OBJECT_ID" IS NOT NULL)
24 rows selected.
|
|