{section}
{column:width=50}
-- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
-- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
SQL> SELECT /*+ gather_plan_statistics */
2 t1.c1, v.c2
3 FROM
4 t1,
5 (SELECT c1, c2, c3 FROM t2
6 UNION ALL
7 SELECT c1, c2, c3 FROM t3) v
8 WHERE
9 t1.c1 = v.c1 AND
10 v.c3 = 1
11 ;
1 dummy
1 dummy
101 dummy
201 dummy
301 dummy
401 dummy
501 dummy
601 dummy
701 dummy
801 dummy
901 dummy
11 개의 행이 선택되었습니다.
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
-- Need Check --
SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor(null,null,'allstats cost last'));
SQL_ID akgr7bafd1kvp, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ t1.c1, v.c2 FROM t1, (SELECT
c1, c2, c3 FROM t2 UNION ALL SELECT c1, c2, c3 FROM t3) v WHERE
t1.c1 = v.c1 AND v.c3 = 1
-- Oracle 11g
-----------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
-----------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 12 (100)| 11 |00:00:00.02 | 35 | | | |
|* 1 | HASH JOIN | | 1 | 11 | 12 (9)| 11 |00:00:00.02 | 35 | 870K| 870K| 1082K (0)|
| 2 | VIEW | | 1 | 11 | 4 (0)| 11 |00:00:00.01 | 9 | | | |
| 3 | UNION-ALL | | 1 | | | 11 |00:00:00.01 | 9 | | | |
|* 4 | TABLE ACCESS FULL | T2 | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 7 | | | |
| 5 | TABLE ACCESS BY INDEX ROWID| T3 | 1 | 1 | 2 (0)| 1 |00:00:00.01 | 2 | | | |
|* 6 | INDEX RANGE SCAN | T3_N2 | 1 | 1 | 1 (0)| 1 |00:00:00.01 | 1 | | | |
| 7 | INDEX FAST FULL SCAN | T1_N1 | 1 | 10000 | 7 (0)| 10000 |00:00:00.01 | 26 | | | |
-----------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
4 - filter("C3"=1)
6 - access("C3"=1)
-- Oracle 10g
------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------
|* 1 | HASH JOIN | | 1 | 11 | 10 (10)| 11 |00:00:00.01 | 33 | 870K| 870K| 1015K (0)|
| 2 | VIEW | | 1 | 11 | 3 (0)| 11 |00:00:00.01 | 8 | | | |
| 3 | UNION-ALL PARTITION | | 1 | | | 11 |00:00:00.01 | 8 | | | |
|* 4 | TABLE ACCESS FULL | T2 | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 6 | | | |
| 5 | TABLE ACCESS BY INDEX ROWID| T3 | 1 | 1 | 2 (0)| 1 |00:00:00.01 | 2 | | | |
|* 6 | INDEX RANGE SCAN | T3_N2 | 1 | 1 | 1 (0)| 1 |00:00:00.01 | 1 | | | |
| 7 | INDEX FAST FULL SCAN | T1_N1 | 1 | 10000 | 6 (0)| 10000 |00:00:00.01 | 25 | | | |
------------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
4 - filter("C3"=1)
6 - access("C3"=1)
-- 1 교재에서는 NESTED LOOPS 사용
-- 7 교재에서는 INDEX RANGE SCAN 사용
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
SQL> SELECT /*+ gather_plan_statistics */
2 t1.c1, v.c2
3 FROM
4 t1,
5 (SELECT c1, MAX(c2) AS c2, MAX(c3) AS c3
6 FROM t2
7 GROUP BY c1) v
8 WHERE
9 t1.c1 = v.c1 AND
10 v.c3 = 1
11 ;
1 dummy
101 dummy
201 dummy
301 dummy
401 dummy
501 dummy
601 dummy
701 dummy
801 dummy
901 dummy
10 개의 행이 선택되었습니다.
-- Need Check --
SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor(null,null,'allstats cost last'));
SQL_ID g7b17adzrfpjf, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ t1.c1, v.c2 FROM t1, (SELECT
c1, MAX(c2) AS c2, MAX(c3) AS c3 FROM t2 GROUP BY c1) v WHERE
t1.c1 = v.c1 AND v.c3 = 1
-- Oracle 11g
---------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 12 (100)| 10 |00:00:00.02 | 33 | | | |
|* 1 | HASH JOIN | | 1 | 10 | 12 (17)| 10 |00:00:00.02 | 33 | 870K| 870K| 1076K (0)|
| 2 | VIEW | | 1 | 10 | 4 (25)| 10 |00:00:00.01 | 7 | | | |
|* 3 | FILTER | | 1 | | | 10 |00:00:00.01 | 7 | | | |
| 4 | HASH GROUP BY | | 1 | 10 | 4 (25)| 1000 |00:00:00.01 | 7 | 766K| 766K| 1253K (0)|
| 5 | TABLE ACCESS FULL| T2 | 1 | 1000 | 3 (0)| 1000 |00:00:00.01 | 7 | | | |
| 6 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 7 (0)| 10000 |00:00:00.01 | 26 | | | |
---------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
3 - filter(MAX("C3")=1)
-- Oracle 10g
---------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------
|* 1 | HASH JOIN | | 1 | 10 | 11 (19)| 10 |00:00:00.01 | 31 | 870K| 870K| 1023K (0)|
| 2 | VIEW | | 1 | 10 | 4 (25)| 10 |00:00:00.01 | 6 | | | |
|* 3 | FILTER | | 1 | | | 10 |00:00:00.01 | 6 | | | |
| 4 | HASH GROUP BY | | 1 | 10 | 4 (25)| 1000 |00:00:00.01 | 6 | | | |
| 5 | TABLE ACCESS FULL| T2 | 1 | 1000 | 3 (0)| 1000 |00:00:00.01 | 6 | | | |
| 6 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 6 (0)| 10000 |00:00:00.01 | 25 | | | |
---------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
3 - filter(MAX("C3")=1)
-- 1 교재에서는 NESTED LOOPS 사용
-- 6 교재에서는 INDEX RANGE SCAN 사용
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
SQL> SELECT /*+ gather_plan_statistics */
2 t1.c1, v.c2
3 FROM
4 t1,
5 (SELECT ROWNUM AS r, c1, c2, c3
6 FROM t2) v
7 WHERE
8 t1.c1 = v.c1 AND
9 v.c3 = 1
10 ;
1 dummy
101 dummy
201 dummy
301 dummy
401 dummy
501 dummy
601 dummy
701 dummy
801 dummy
901 dummy
10 개의 행이 선택되었습니다.
-- Need Check --
SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor(null,null,'allstats cost last'));
SQL_ID 8h6g72wb5rgyy, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ t1.c1, v.c2 FROM t1, (SELECT
ROWNUM AS r, c1, c2, c3 FROM t2) v WHERE t1.c1 = v.c1 AND v.c3 = 1
-- Oracle 11g
---------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 11 (100)| 10 |00:00:00.02 | 33 | | | |
|* 1 | HASH JOIN | | 1 | 1000 | 11 (10)| 10 |00:00:00.02 | 33 | 870K| 870K| 1082K (0)|
|* 2 | VIEW | | 1 | 1000 | 3 (0)| 10 |00:00:00.01 | 7 | | | |
| 3 | COUNT | | 1 | | | 1000 |00:00:00.01 | 7 | | | |
| 4 | TABLE ACCESS FULL | T2 | 1 | 1000 | 3 (0)| 1000 |00:00:00.01 | 7 | | | |
| 5 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 7 (0)| 10000 |00:00:00.01 | 26 | | | |
---------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
2 - filter("V"."C3"=1)
-- Oracle 10g
---------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------
|* 1 | HASH JOIN | | 1 | 1000 | 10 (10)| 10 |00:00:00.01 | 31 | 870K| 870K| 1017K (0)|
|* 2 | VIEW | | 1 | 1000 | 3 (0)| 10 |00:00:00.01 | 6 | | | |
| 3 | COUNT | | 1 | | | 1000 |00:00:00.01 | 6 | | | |
| 4 | TABLE ACCESS FULL | T2 | 1 | 1000 | 3 (0)| 1000 |00:00:00.01 | 6 | | | |
| 5 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 6 (0)| 10000 |00:00:00.01 | 25 | | | |
---------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
2 - filter("V"."C3"=1)
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
SQL> SELECT /*+ gather_plan_statistics */
2 t1.c1, v.c2,
3 CURSOR(SELECT * FROM t3 WHERE t3.c1 = t1.c1) AS cs
4 FROM
5 t1,
6 (SELECT c1, c2, c3
7 FROM t2) v
8 WHERE
9 t1.c1 = v.c1 AND
10 v.c3 = 1
11 ;
1 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
1 dummy 1
101 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
201 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
301 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
401 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
501 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
601 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
701 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
801 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
901 dummy CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
선택된 레코드가 없습니다.
10 개의 행이 선택되었습니다.
-- Need Check --
SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor(null,null,'allstats cost last'));
SQL_ID 76mxg72avxqyw, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ t1.c1, v.c2, CURSOR(SELECT *
FROM t3 WHERE t3.c1 = t1.c1) AS csr FROM t1, (SELECT c1, c2, c3
FROM t2) v WHERE t1.c1 = v.c1 AND v.c3 = 1
-- Oracle 11g
---------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 11 (100)| 10 |00:00:00.02 | 37 | | | |
| 1 | TABLE ACCESS BY INDEX ROWID| T3 | 0 | 1 | 2 (0)| 0 |00:00:00.01 | 0 | | | |
|* 2 | INDEX RANGE SCAN | T3_N1 | 0 | 1 | 1 (0)| 0 |00:00:00.01 | 0 | | | |
|* 3 | HASH JOIN | | 1 | 10 | 11 (10)| 10 |00:00:00.02 | 37 | 870K| 870K| 1055K (0)|
| 4 | VIEW | | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 7 | | | |
|* 5 | TABLE ACCESS FULL | T2 | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 7 | | | |
| 6 | INDEX FAST FULL SCAN | T1_N1 | 1 | 10000 | 7 (0)| 10000 |00:00:00.01 | 30 | | | |
---------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("T3"."C1"=:B1)
3 - access("T1"."C1"="V"."C1")
5 - filter("C3"=1)
-- Oracle 10g
---------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------------
| 1 | TABLE ACCESS BY INDEX ROWID| T3 | 0 | 1 | 2 (0)| 0 |00:00:00.01 | 0 | | | |
|* 2 | INDEX RANGE SCAN | T3_N1 | 0 | 1 | 1 (0)| 0 |00:00:00.01 | 0 | | | |
|* 3 | HASH JOIN | | 1 | 10 | 10 (10)| 10 |00:00:00.01 | 35 | 870K| 870K| 1017K (0)|
| 4 | VIEW | | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 6 | | | |
|* 5 | TABLE ACCESS FULL | T2 | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 6 | | | |
| 6 | INDEX FAST FULL SCAN | T1_N1 | 1 | 10000 | 6 (0)| 10000 |00:00:00.01 | 29 | | | |
---------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("T3"."C1"=:B1)
3 - access("T1"."C1"="V"."C1")
5 - filter("C3"=1)
-- 3 교재에서는 NESTED LOOPS 사용
-- 6 교재에서는 INDEX RANGE SCAN 사용
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
SQL> SELECT /*+ gather_plan_statistics */
2 t1.c1, v.*
3 FROM
4 t1,
5 (SELECT ROW_NUMBER() OVER (ORDER BY c1) AS rn,
6 c1, c2, c3
7 FROM t2) v
8 WHERE
9 t1.c1 = v.c1 AND
10 v.c3 = 1
11 ;
1 1 1 dummy 1
101 101 101 dummy 1
201 201 201 dummy 1
301 301 301 dummy 1
401 401 401 dummy 1
501 501 501 dummy 1
601 601 601 dummy 1
701 701 701 dummy 1
801 801 801 dummy 1
901 901 901 dummy 1
10 개의 행이 선택되었습니다.
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor(null,null,'allstats cost last'));
SQL_ID 2tmvfh1zhn3p8, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ t1.c1, v.* FROM t1, (SELECT
ROW_NUMBER() OVER (ORDER BY c1) AS rn, c1, c2, c3 FROM t2)
v WHERE t1.c1 = v.c1 AND v.c3 = 1
Plan hash value: 784523758
---------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 12 (100)| 10 |00:00:00.02 | 33 | | | |
|* 1 | HASH JOIN | | 1 | 1000 | 12 (17)| 10 |00:00:00.02 | 33 | 816K| 816K| 1073K (0)|
|* 2 | VIEW | | 1 | 1000 | 4 (25)| 10 |00:00:00.01 | 7 | | | |
| 3 | WINDOW SORT | | 1 | 1000 | 4 (25)| 1000 |00:00:00.01 | 7 | 38912 | 38912 |34816 (0)|
| 4 | TABLE ACCESS FULL | T2 | 1 | 1000 | 3 (0)| 1000 |00:00:00.01 | 7 | | | |
| 5 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 7 (0)| 10000 |00:00:00.01 | 26 | | | |
---------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
2 - filter("V"."C3"=1)
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
SQL> SELECT /*+ gather_plan_statistics */
2 t1.c1, v.c2
3 FROM
4 t1,
5 (SELECT c1, c3, COUNT(*) AS c2
6 FROM t2
7 GROUP BY c1, c3) v
8 WHERE
9 t1.c1 = v.c1 AND
10 v.c3 = 1
11 ;
1 1
101 1
201 1
301 1
401 1
501 1
601 1
701 1
801 1
901 1
10 개의 행이 선택되었습니다.
-- Need Check --
SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor(null,null,'allstats cost last'));
SQL_ID 1j3wzw9a0nz11, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ t1.c1, v.c2 FROM t1, (SELECT
c1, c3, COUNT(*) AS c2 FROM t2 GROUP BY c1, c3) v WHERE t1.c1
= v.c1 AND v.c3 = 1
-- Oracle 11g
---------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 12 (100)| 10 |00:00:00.02 | 33 | | | |
|* 1 | HASH JOIN | | 1 | 8 | 12 (17)| 10 |00:00:00.02 | 33 | 968K| 968K| 1082K (0)|
| 2 | VIEW | | 1 | 8 | 4 (25)| 10 |00:00:00.01 | 7 | | | |
| 3 | HASH GROUP BY | | 1 | 8 | 4 (25)| 10 |00:00:00.01 | 7 | 848K| 848K| 1011K (0)|
|* 4 | TABLE ACCESS FULL | T2 | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 7 | | | |
| 5 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 7 (0)| 10000 |00:00:00.01 | 26 | | | |
---------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
4 - filter("C3"=1)
-- Oracle 10g
---------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------
|* 1 | HASH JOIN | | 1 | 10 | 11 (19)| 10 |00:00:00.01 | 31 | 968K| 968K| 1016K (0)|
| 2 | VIEW | | 1 | 10 | 4 (25)| 10 |00:00:00.01 | 6 | | | |
| 3 | HASH GROUP BY | | 1 | 10 | 4 (25)| 10 |00:00:00.01 | 6 | | | |
|* 4 | TABLE ACCESS FULL | T2 | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 6 | | | |
| 5 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 6 (0)| 10000 |00:00:00.01 | 25 | | | |
---------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."C1"="V"."C1")
4 - filter("C3"=1)
-- 1 교재에서는 NESTED LOOPS 사용
-- 5 교재에서는 INDEX RANGE SCAN 사용
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
SQL> SELECT /*+ gather_plan_statistics */
2 t1.c1, v.c2
3 FROM
4 t1,
5 (SELECT c1, c3, COUNT(*) AS c2
6 FROM t2
7 GROUP BY c1, c3) v
8 WHERE
9 t1.c1 = v.c1 AND
10 t1.c3 = 1 -- v.c3 = 1
11 ;
401 1
201 1
301 1
1 1
801 1
901 1
701 1
101 1
501 1
601 1
10 개의 행이 선택되었습니다.
SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor(null,null,'allstats cost last'));
SQL_ID g465uavtbp9kc, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ t1.c1, v.c2 FROM t1, (SELECT
c1, c3, COUNT(*) AS c2 FROM t2 GROUP BY c1, c3) v WHERE t1.c1
= v.c1 AND t1.c3 = 1 -- v.c3 = 1
-- Oracle 11g
------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 16 (100)| 10 |00:00:00.01 | 45 | | | |
| 1 | HASH GROUP BY | | 1 | 100 | 16 (13)| 10 |00:00:00.01 | 45 | 781K| 781K| 1002K (0)|
|* 2 | HASH JOIN | | 1 | 100 | 15 (7)| 10 |00:00:00.01 | 45 | 870K| 870K| 1207K (0)|
|* 3 | TABLE ACCESS FULL| T1 | 1 | 100 | 11 (0)| 100 |00:00:00.01 | 38 | | | |
| 4 | TABLE ACCESS FULL| T2 | 1 | 1000 | 3 (0)| 1000 |00:00:00.01 | 7 | | | |
------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("T1"."C1"="C1")
3 - filter("T1"."C3"=1)
{column}
{column:width=50}
{column}
{section}
{section}
{column:width=50}
-- Need Check --
SQL> SELECT /*+ gather_plan_statistics */
2 t1.c1, v.c2
3 FROM
4 t1,
5 (SELECT /*+ merge */ c1, c3, COUNT(*) AS c2
6 FROM t2
7 GROUP BY c1, c3) v
8 WHERE
9 t1.c1 = v.c1 AND
10 v.c3 = 1
11 ;
401 1
201 1
301 1
1 1
801 1
901 1
701 1
101 1
501 1
601 1
10 개의 행이 선택되었습니다.
SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor(null,null,'allstats cost last'));
SQL_ID dxz4b1bbuym82, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ t1.c1, v.c2 FROM t1, (SELECT
/*+ merge */ c1, c3, COUNT(*) AS c2 FROM t2 GROUP BY c1, c3) v
WHERE t1.c1 = v.c1 AND v.c3 = 1
-- Oracle 11g
----------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
----------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 12 (100)| 10 |00:00:00.02 | 32 | | | |
| 1 | HASH GROUP BY | | 1 | 10 | 12 (17)| 10 |00:00:00.02 | 32 | 781K| 781K| 1002K (0)|
|* 2 | HASH JOIN | | 1 | 10 | 11 (10)| 10 |00:00:00.02 | 32 | 968K| 968K| 1080K (0)|
|* 3 | TABLE ACCESS FULL | T2 | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 7 | | | |
| 4 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 7 (0)| 10000 |00:00:00.01 | 25 | | | |
----------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("T1"."C1"="C1")
3 - filter("C3"=1)
-- Oracle 10g
----------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
----------------------------------------------------------------------------------------------------------------------------------
| 1 | HASH GROUP BY | | 1 | 10 | 11 (19)| 10 |00:00:00.01 | 30 | | | |
|* 2 | HASH JOIN | | 1 | 10 | 10 (10)| 10 |00:00:00.01 | 30 | 968K| 968K| 1017K (0)|
|* 3 | TABLE ACCESS FULL | T2 | 1 | 10 | 3 (0)| 10 |00:00:00.01 | 6 | | | |
| 4 | INDEX FAST FULL SCAN| T1_N1 | 1 | 10000 | 6 (0)| 10000 |00:00:00.01 | 24 | | | |
----------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("T1"."C1"="C1")
3 - filter("C3"=1)
-- 2 교재에서는 NESTED LOOPS 사용
-- 4 교재에서는 INDEX RANGE SCAN 사용
{column}
{column:width=50}
{column}
{section}