1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
Connected to Oracle9i Enterprise Edition Release 9.2.0.5.0
Connected as mni
SQL>
SQL> explain plan for Select *
2 From emp where deptno in (select deptno
3 from dept
4 where loc like '%'
5 union
6 select deptno
7 from dept
8 where loc = 'BOSTON'
9 )
10 ;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 17 | 833 | 11 |
|* 1 | HASH JOIN | | 17 | 833 | 11 |
| 2 | VIEW | VW_NSO_1 | 5 | 65 | 8 |
| 3 | SORT UNIQUE | | 5 | 55 | 8 |
| 4 | UNION-ALL | | | | |
|* 5 | TABLE ACCESS FULL| DEPT | 4 | 44 | 2 |
|* 6 | TABLE ACCESS FULL| DEPT | 1 | 11 | 2 |
| 7 | TABLE ACCESS FULL | EMP | 10 | 360 | 2 |
---------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("EMP"."DEPTNO"="VW_NSO_1"."$nso_col_1")
5 - filter("DEPT"."LOC" LIKE '%')
6 - filter("DEPT"."LOC"='BOSTON')
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Note: cpu costing is off
22 rows selected
SQL>
SQL> explain plan for Select *
2 From emp where deptno in (select deptno
3 from dept
4 where loc like '%'
5 union all
6 select deptno
7 from dept
8 where loc = 'BOSTON'
9 )
10 ;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%C
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 17 | 663 | 4 (
| 1 | NESTED LOOPS | | 17 | 663 | 4 (
| 2 | TABLE ACCESS FULL | EMP | 10 | 360 | 2
| 3 | VIEW | VW_NSO_1 | 2 | 6 |
| 4 | SORT UNIQUE | | 5 | |
| 5 | UNION-ALL PARTITION | | | |
|* 6 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 11 | 2 (
|* 7 | INDEX UNIQUE SCAN | PK_DEPT | 1 | |
|* 8 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 11 | 2 (
|* 9 | INDEX UNIQUE SCAN | PK_DEPT | 1 | |
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
6 - filter("DEPT"."LOC" LIKE '%')
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
7 - access("DEPT"."DEPTNO"="EMP"."DEPTNO")
8 - filter("DEPT"."LOC"='BOSTON')
9 - access("DEPT"."DEPTNO"="EMP"."DEPTNO")
23 rows selected
SQL> |