Close Beta | 구현된 내부 코드가 이미 존재하고, 파라미터 또는 비공식 힌트를 사용하여 Query Transformation이 일어나게끔 할 수 있음. |
Open Beta | 내부 코드가 기본값으로 활성화되지만 Cost-Based는 아님. 따라서 항상 변환이 일어남. |
Release | 옵티마이저가 원래 SQL과 변환된 SQL의 양쪽 비용 모두를 계산해서 더 비용이 낮은 쪽을 선택함. 힌트는 deprecatted됨. |
-- 총 20,000명의 사원이 여섯 개 부서로 나뉘도록 테이블을 생성함.
-- 각 사원은 서로 다른 식별자(EMP_NO)를 가지며, 급여(SALARY)도 서로 중복되지 않는다.
CREATE TABLE EMP(DEPT_NO NOT NULL,
SAL,
EMP_NO NOT NULL,
PADDING,
CONSTRAINT E_PK PRIMARY KEY(EMP_NO))
AS
WITH GENERATOR AS (SELECT ROWNUM ID
FROM ALL_OBJECTS
WHERE ROWNUM <= 1000)
SELECT /*+ ORDERED USE_NL(V2) */
MOD(ROWNUM, 6),
ROWNUM,
ROWNUM,
RPAD('X', 60)
FROM GENERATOR V1,
GENERATOR V2
WHERE ROWNUM <= 20000
;
BEGIN
DBMS_STATS.GATHER_TABLE_STATS(OWNNAME => USER,
TABNAME => 'EMP',
CASCADE => TRUE,
ESTIMATE_PERCENT => NULL,
METHOD_OPT =>'FOR ALL COLUMNS SIZE 1');
END;
/
ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE = '8.1.7';
EXPLAIN PLAN FOR
SELECT OUTER.*
FROM EMP OUTER
WHERE OUTER.SAL > (SELECT /*+ NO_UNNEST */
AVG(INNER.SAL)
FROM EMP INNER
WHERE INNER.DEPT_NO = OUTER.DEPT_NO);
@XPLAN3;
------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1000 | 72000 | 35 |
|* 1 | FILTER | | | | |
| 2 | TABLE ACCESS FULL | EMP | 1000 | 72000 | 35 |
| 3 | SORT AGGREGATE | | 1 | 8 | |
|* 4 | TABLE ACCESS FULL| EMP | 3333 | 26664 | 35 |
------------------------------------------------------------
Outline Data
-------------
/*+
BEGIN_OUTLINE_DATA
FULL(@"SEL$2" "INNER"@"SEL$2")
FULL(@"SEL$1" "OUTER"@"SEL$1")
OUTLINE_LEAF(@"SEL$1")
OUTLINE_LEAF(@"SEL$2")
OPT_PARAM('_fast_full_scan_enabled' 'false')
OPTIMIZER_FEATURES_ENABLE('8.1.7')
IGNORE_OPTIM_EMBEDDED_HINTS
END_OUTLINE_DATA
*/
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OUTER"."SAL"> (SELECT /*+ NO_UNNEST */
AVG("INNER"."SAL")
FROM "EMP" "INNER" WHERE "INNER"."DEPT_NO"=:B1))
4 - filter("INNER"."DEPT_NO"=:B1)
Note
-----
- cpu costing is off (consider enabling it)
;
ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE = '9.2.0.8';
EXPLAIN PLAN FOR
SELECT OUTER.*
FROM EMP OUTER
WHERE OUTER.SAL > (SELECT /*+ NO_UNNEST */
AVG(INNER.SAL)
FROM EMP INNER
WHERE INNER.DEPT_NO = OUTER.DEPT_NO);
@XPLAN3;
------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1000 | 72000 | 72 |
|* 1 | FILTER | | | | |
| 2 | TABLE ACCESS FULL | EMP | 1000 | 72000 | 36 |
| 3 | SORT AGGREGATE | | 1 | 8 | |
|* 4 | TABLE ACCESS FULL| EMP | 3333 | 26664 | 36 |
------------------------------------------------------------
Outline Data
-------------
/*+
BEGIN_OUTLINE_DATA
FULL(@"SEL$2" "INNER"@"SEL$2")
FULL(@"SEL$1" "OUTER"@"SEL$1")
OUTLINE_LEAF(@"SEL$1")
OUTLINE_LEAF(@"SEL$2")
OPT_PARAM('_optim_peek_user_binds' 'false')
OPT_PARAM('_fast_full_scan_enabled' 'false')
OPT_PARAM('_b_tree_bitmap_plans' 'false')
OPTIMIZER_FEATURES_ENABLE('9.2.0.8')
IGNORE_OPTIM_EMBEDDED_HINTS
END_OUTLINE_DATA
*/
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OUTER"."SAL"> (SELECT /*+ NO_UNNEST */
AVG("INNER"."SAL")
FROM "EMP" "INNER" WHERE "INNER"."DEPT_NO"=:B1))
4 - filter("INNER"."DEPT_NO"=:B1)
Note
-----
- cpu costing is off (consider enabling it)
;
ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE = '10.2.0.3';
EXPLAIN PLAN FOR
SELECT OUTER.*
FROM EMP OUTER
WHERE OUTER.SAL > (SELECT /*+ NO_UNNEST */
AVG(INNER.SAL)
FROM EMP INNER
WHERE INNER.DEPT_NO = OUTER.DEPT_NO);
@XPLAN3;
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 167 | 12024 | 452 (1)| 00:00:06 |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL | EMP | 20000 | 1406K| 65 (2)| 00:00:01 |
| 3 | SORT AGGREGATE | | 1 | 8 | | |
|* 4 | TABLE ACCESS FULL| EMP | 3333 | 26664 | 65 (2)| 00:00:01 |
----------------------------------------------------------------------------
Outline Data
-------------
/*+
BEGIN_OUTLINE_DATA
FULL(@"SEL$2" "INNER"@"SEL$2")
FULL(@"SEL$1" "OUTER"@"SEL$1")
OUTLINE(@"SEL$1")
OUTLINE(@"SEL$2")
OUTLINE_LEAF(@"SEL$1")
OUTLINE_LEAF(@"SEL$2")
ALL_ROWS
OPT_PARAM('_optim_peek_user_binds' 'false')
OPT_PARAM('_fast_full_scan_enabled' 'false')
OPT_PARAM('_b_tree_bitmap_plans' 'false')
OPTIMIZER_FEATURES_ENABLE('10.2.0.3')
IGNORE_OPTIM_EMBEDDED_HINTS
END_OUTLINE_DATA
*/
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OUTER"."SAL"> (SELECT /*+ NO_UNNEST */
AVG("INNER"."SAL")
FROM "EMP" "INNER" WHERE "INNER"."DEPT_NO"=:B1))
4 - filter("INNER"."DEPT_NO"=:B1)
- 강좌 URL : http://www.gurubee.net/lecture/4421
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.