제 PC 가 이상한건지, 잘 안올라가네요. 우선 에버노트 공유 기능으로 발표 자료 올려요..
주중에 다시 올리겠습니다. (__)(--)(__)
( 꼬릿말 ) 예전에 HTML 형식 비슷하게 Edit 하는 메뉴가 안보이는데 없어졌나요 ㅇㅇ?
Logical Optimizer 2번째 발표 - 1
http://www.evernote.com/shard/s283/sh/b0d2ce03-001d-48c8-890a-4c1a5546564a/8eeb7170ce31da6add9ac105b977ca5e
Logical Optimizer 2번째 발표 - 2
http://www.evernote.com/shard/s283/sh/bb0dd5f6-99fc-437f-b486-5f3cfecef322/2c44fed07b54ec97f571faad8ea1db60
Logical Optimizer 2번째 발표 - 3
http://www.evernote.com/shard/s283/sh/28294b01-1d88-4b3d-87db-19e2b959f7e3/567d25d930b47800d4e0c3a7e672edec
다시
: 조인을 수행하기 전에 Group By 를 먼저 수행하여 건수를 줄이고 나중에 조인을 수행함으로써 조인 건수를 획기적으로 감소 시키는게 목적
: PLACE_GROUP_BY / NO_PLACE_GROUP_BY
: _optimizer_group_by_plance = true ( Default )
h2.오라클이 변경한 SQL
****************************************
Cost-Based Group-By/Distinct Placement
****************************************
GBP/DP: Checking validity of GBP/DP for query block SEL$1 (#1)
GBP: Checking validity of group-by placement for query block SEL$1 (#1)
GBP: Using search type: exhaustive
GBP: Considering group-by placement on query block SEL$1 (#1)
GBP: Starting iteration 1, state space = (1,2) : (0,0)
GBP: Original query
...
GBP: Costing transformed query.
...
---------------------
QUERY BLOCK SIGNATURE
---------------------
signature (optimizer): qb_name=SEL$62C25666 nbfros=2 flg=0
fro(0): flg=1 objn=0 hint_alias="VW_GBC_5"@"SEL$0737CF93"
fro(1): flg=0 objn=102419 hint_alias="C"@"SEL$1"
#. 참고 : TQ(Table Queue )
1. TQ 는 Process 간의 데이터를 주고받는 기능을 함
2. 하나의 TQ는 여러 개의 Parallel Slave 를 가짐
3. TQ는 Parallel Query 수행시 생성됨
: GBY_PUSHDOWN/NO_GBY_PUSHDOWN (11g)
_groupby_nopushdown_cut_ratio = 0 을 통해서 Group By Push down 을 강제할 수 있다.(10g, Default 는 3, 옵티마이져 자동 판단)
GROUP BY PUSH DOWN 이 적용되지 않는 PLAN
: 정상적으로 Group By 가 한번만 수행됨 : TQ의 일량이 Group By Push Down 이 적용된 SQL 에 비해 918 K 로 약 12750 배 증가 (( 918*1024) /72 )
*********************************
Number of join permutations tried: 1
*********************************
Enumerating distribution method (advanced)
GROUP BY adjustment factor: 1.000000
GROUP BY cardinality: 72.000000, TABLE cardinality: 918843.000000
Costing group-by pushdown:
SORT ressource Sort statistics
Sort width: 162 Area size: 143360 Max Area size: 28730368
Degree: 1
Blocks to Sort: 422 Row size: 15 Total Rows: 229711
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 212689832
Total Temp space used: 0
Distribution cost: resc_cpu: 91885304 resp_cpu: 22971326
Costing final group-by:
Subtracting no-pushdown group-by:
SORT ressource Sort statistics
: FACTORIZE_JOIN / NO_FACTORIZE_JOIN
: _optimizer_join_factorization = true ( Default ) , False 설정 시 JE 기능 사용 불가
: PLAN 에서 볼 수 있듯이 VW_JF_SET$0A277F6D 으로 시작하는 인라인뷰 명은 JF 가 수행되었음을 나타냄
: SET$1 ==>전체에 해당하는 쿼리 블록, SEL$1 => Union All 중 윗부분, SEL$2 => Union All 중 아랫 부분
마. 10053 Trace
먼저 10053 Trace 용어 설명 부분에 JF 가 아래처럼 추가
The following abbreviations are used by optimizer trace.
....
JF - join factorization
1. Search Type 이 Exhaustive 이므로 가능한 모든 경우의 수를 고려하겠다는 의미 ( Exhaustive )
2. JF 수행 검사
***********************************
Cost-Based Join Factorization
***********************************
Join-Factorization on query block SET$1 (#1)
JF: Using search type: exhaustive
JF: Checking validity of join factorization for query block SET$1 (#1)
JF: Generate basic transformation units
Validating JF unit: (branch: {2, 3} table: {S, S})
passed JF validation
JF: unit inserted into state space: (branch: {2, 3} table: {S, S})
(branch: {2, 3} table: {S, S})
Validating JF unit: (branch: {2, 3} table: {C, C})
rejected: table filter predicates do not match
JF: Generate transformation units from basic units
JF: Starting iteration 1, state space = {}
JF: Transformed query
******* UNPARSED QUERY IS *******
(SELECT /*+ USE_HASH ("C") USE_HASH ("S") */ "S"."PROD_ID" "PROD_ID","S"."CUST_ID" "CUST_ID","S"."QUANTITY_SOLD" "QUANTITY_SOLD","S"."AMOUNT_SOLD" "AMOUNT_SOLD","C"."CHANNEL_DESC" "CHANNEL_DESC" FROM "TLO"."SALES" "S","TLO"."CHANNELS" "C" WHERE "C"."CHANNEL_ID"="S"."CHANNEL_ID" AND "C"."CHANNEL_ID"=3) UNION ALL (SELECT /*+ USE_HASH ("C") USE_HASH ("S") */ "S"."PROD_ID" "PROD_ID","S"."CUST_ID" "CUST_ID","S"."QUANTITY_SOLD" "QUANTITY_SOLD","S"."AMOUNT_SOLD" "AMOUNT_SOLD","C"."CHANNEL_DESC" "CHANNEL_DESC" FROM "TLO"."SALES" "S","TLO"."CHANNELS" "C" WHERE "C"."CHANNEL_ID"="S"."CHANNEL_ID" AND "C"."CHANNEL_ID"=9)
FPD: Considering simple filter push in query block SET$1 (#1)
??
FPD: Considering simple filter push in query block SEL$1 (#3)
"C"."CHANNEL_ID"="S"."CHANNEL_ID" AND "C"."CHANNEL_ID"=3
try to generate transitive predicate from check constraints for query block SEL$1 (#3)
finally: "S"."CHANNEL_ID"=3 AND "C"."CHANNEL_ID"=3
FPD: Considering simple filter push in query block SEL$2 (#2)
"C"."CHANNEL_ID"="S"."CHANNEL_ID" AND "C"."CHANNEL_ID"=9
try to generate transitive predicate from check constraints for query block SEL$2 (#2)
finally: "S"."CHANNEL_ID"=9 AND "C"."CHANNEL_ID"=9
JF: Costing transformed query.
CBQT: Looking for cost annotations for query block SEL$1, key = SEL$1_00000000_0
CBQT: Could not find stored cost annotations.
CBQT: Looking for cost annotations for query block SEL$2, key = SEL$2_00000000_0
CBQT: Could not find stored cost annotations.
kkoqbc: optimizing query block SEL$1 (#3)
:
call(in-use=4584, alloc=16360), compile(in-use=188776, alloc=202068), execution(in-use=3116, alloc=4060)
kkoqbc-subheap (create addr=0xb6a2fad0)
kkoqbc: finish optimizing query block SET$1 (#1)
CBQT: Saved costed qb# 3 (SEL$1), key = SEL$1_00000000_0
CBQT: Saved costed qb# 2 (SEL$2), key = SEL$2_00000000_0
CBQT: Saved costed qb# 1 (SET$1), key = SET$1_00000000_0
JF: Updated best state, Cost = 1600.30
JF: Starting iteration 2, state space = {(branch: {2, 3} table: {S, S})}
Registered qb: SET$540DB43F 0xb699aaf4 (JOIN FACTORIZATION SET QUERY BLOCK SET$1; SET$1; LIST)
*********************************
Number of join permutations tried: 1
*********************************
JF: Updated best state, Cost = 1201.84
JF: Transferring best state space to preseved query.
JF: Transferring best state space to original query.
: From 절의 (소량의) Dimension 테이블을 서브쿼리로 변환하고 DSJ 기능을 이용하여 Bitmap 연산을 수행하라.
!!! 책 예제는 11.1 사용 예제
Dimension 테이블이 서브쿼리로 변환되는 특징( From 절에 있던 Dimension 테이블은 그대로 존재, Dimenstion 테이블이 2개 )
STAR_TRANSFORMATION / NO_STAR_TRANSFORMATION ( 가끔 FACT 테이블 못 찾는 경우 FACT 힌트 추가 )
( Bitmap Operation )
BITMAP INDEX
SINGLE VALUE : 인덱스 블록 내에서 하나의 키 값에 해당하는 비트맵을 검색
RANGE SCAN : 하나의 키 값에 해당하는 여러 개의 비트맵을 검색
FULL SCAN : 시작/종료값이 제공되지 않은 경우 비트맵 전체를 스캔
ITMAP KEY ITERATION
한 테이블에서 얻은 각각의 로우들을 특정 비트맵 인덱스에 대해 연속해서 확인하여 비트맵을 찾는것
뒤에 비트맵 머지가 수행되어 하나의 비트맵으로 합쳐지며 스타 변형 조인에서 나타남
BITMAP MERGE
범 위 스캔으로 얻은 몇 개의 비트맵을 하나로 머지
SQL> set linesize 150
SQL> explain plan for SELECT p.prod_id
2 ,c.channel_id
3 ,SUM(quantity_sold) AS qs
4 ,SUM(amount_sold) AS amt
5 FROM sales s, channels c, products p
6 WHERE s.channel_id = c.channel_id
7 AND c.channel_desc ='Internet'
8 AND s.prod_id = p.prod_id
9 AND p.prod_category_desc ='Photo'
10 GROUP BY p.prod_id, c.channel_id ;
Explained.
SQL> set pagesize 2000
SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 258650688
----------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
----------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 221 | 122 (2)| 00:00:02 | | |
| 1 | HASH GROUP BY | | 1 | 221 | 122 (2)| 00:00:02 | | |
|* 2 | HASH JOIN | | 115 | 25415 | 121 (1)| 00:00:02 | | |
| 3 | MERGE JOIN CARTESIAN | | 1 | 188 | 6 (0)| 00:00:01 | | |
|* 4 | TABLE ACCESS FULL | CHANNELS | 1 | 15 | 3 (0)| 00:00:01 | | |
| 5 | BUFFER SORT | | 1 | 173 | 3 (0)| 00:00:01 | | |
|* 6 | TABLE ACCESS FULL | PRODUCTS | 1 | 173 | 3 (0)| 00:00:01 | | |
| 7 | VIEW | VW_ST_34C376F1 | 3190 | 102K| 115 (1)| 00:00:02 | | |
| 8 | NESTED LOOPS | | 3190 | 149K| 109 (1)| 00:00:02 | | |
| 9 | PARTITION RANGE ALL | | 3190 | 60618 | 6 (0)| 00:00:01 | 1 | 28 |
| 10 | BITMAP CONVERSION TO ROWIDS| | 3190 | 60618 | 6 (0)| 00:00:01 | | |
| 11 | BITMAP AND | | | | | | | |
| 12 | BITMAP MERGE | | | | | | | |
| 13 | BITMAP KEY ITERATION | | | | | | | |
| 14 | BUFFER SORT | | | | | | | |
|* 15 | TABLE ACCESS FULL | PRODUCTS | 1 | 173 | 3 (0)| 00:00:01 | | |
|* 16 | BITMAP INDEX RANGE SCAN| SALES_PROD_BIX | | | | | 1 | 28 |
| 17 | BITMAP MERGE | | | | | | | |
| 18 | BITMAP KEY ITERATION | | | | | | | |
| 19 | BUFFER SORT | | | | | | | |
|* 20 | TABLE ACCESS FULL | CHANNELS | 1 | 15 | 3 (0)| 00:00:01 | | |
|* 21 | BITMAP INDEX RANGE SCAN| SALES_CHANNEL_BIX | | | | | 1 | 28 |
| 22 | TABLE ACCESS BY USER ROWID | SALES | 1 | 29 | 108 (0)| 00:00:02 | ROWID | ROWID |
----------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ITEM_2"="C"."CHANNEL_ID" AND "ITEM_1"="P"."PROD_ID")
4 - filter("C"."CHANNEL_DESC"='Internet')
6 - filter("P"."PROD_CATEGORY_DESC"='Photo')
15 - filter("P"."PROD_CATEGORY_DESC"='Photo')
16 - access("S"."PROD_ID"="P"."PROD_ID")
20 - filter("C"."CHANNEL_DESC"='Internet')
21 - access("S"."CHANNEL_ID"="C"."CHANNEL_ID")
Note
-----
- star transformation used for this statement
44 rows selected.
( ST 수행 시 )
-------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
-------------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 10 |00:00:00.13 | 699 | | | |
| 1 | HASH GROUP BY | | 1 | 1 | 10 |00:00:00.13 | 699 | 830K| 830K| 1118K (0)|
|* 2 | HASH JOIN | | 1 | 1595 | 13223 |00:00:00.11 | 699 | 1306K| 1306K| 1041K (0)|
| 3 | MERGE JOIN CARTESIAN | | 1 | 1 | 10 |00:00:00.01 | 12 | | | |
|* 4 | TABLE ACCESS FULL | CHANNELS | 1 | 1 | 1 |00:00:00.01 | 6 | | | |
| 5 | BUFFER SORT | | 1 | 10 | 10 |00:00:00.01 | 6 | 2048 | 2048 | 2048 (0)|
|* 6 | TABLE ACCESS FULL | PRODUCTS | 1 | 10 | 10 |00:00:00.01 | 6 | | | |
| 7 | VIEW | VW_ST_34C376F1 | 1 | 31904 | 13223 |00:00:00.08 | 687 | | | |
| 8 | NESTED LOOPS | | 1 | 31904 | 13223 |00:00:00.07 | 687 | | | |
| 9 | PARTITION RANGE ALL | | 1 | 31904 | 13223 |00:00:00.02 | 242 | | | |
| 10 | BITMAP CONVERSION TO ROWIDS| | 28 | 31904 | 13223 |00:00:00.01 | 242 | | | |
| 11 | BITMAP AND | | 28 | | 16 |00:00:00.01 | 242 | | | |
| 12 | BITMAP MERGE | | 28 | | 16 |00:00:00.01 | 53 | 1024K| 512K| 8192 (0)|
| 13 | BITMAP KEY ITERATION | | 28 | | 20 |00:00:00.01 | 53 | | | |
| 14 | BUFFER SORT | | 28 | | 28 |00:00:00.01 | 6 | 73728 | 73728 | |
|* 15 | TABLE ACCESS FULL | CHANNELS | 1 | 1 | 1 |00:00:00.01 | 6 | | | |
|* 16 | BITMAP INDEX RANGE SCAN| SALES_CHANNEL_BIX | 28 | | 20 |00:00:00.01 | 47 | | | |
| 17 | BITMAP MERGE | | 28 | | 16 |00:00:00.01 | 189 | 1024K| 512K| 3072 (0)|
| 18 | BITMAP KEY ITERATION | | 28 | | 132 |00:00:00.01 | 189 | | | |
| 19 | BUFFER SORT | | 28 | | 160 |00:00:00.01 | 6 | 73728 | 73728 | |
|* 20 | TABLE ACCESS FULL | PRODUCTS | 5 | 10 | 10 |00:00:00.01 | 6 | | | |
|* 21 | BITMAP INDEX RANGE SCAN| SALES_PROD_BIX | 160 | | 132 |00:00:00.01 | 183 | | | |
| 22 | TABLE ACCESS BY USER ROWID | SALES | 13223 | 1 | 13223 |00:00:00.03 | 445 | | | |
-------------------------------------------------------------------------------------------------------------------------------------------
( ST 수행 미수행시 )
-----------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
-----------------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 10 |00:00:00.46 | 3700 | | | |
| 1 | HASH GROUP BY | | 1 | 8 | 10 |00:00:00.46 | 3700 | 830K| 830K| 1111K (0)|
|* 2 | HASH JOIN | | 1 | 31904 | 13223 |00:00:00.29 | 3700 | 1517K| 1517K| 1477K (0)|
|* 3 | TABLE ACCESS FULL | PRODUCTS | 1 | 10 | 10 |00:00:00.01 | 6 | | | |
| 4 | NESTED LOOPS | | 1 | | 118K|00:00:00.56 | 3694 | | | |
| 5 | NESTED LOOPS | | 1 | 229K| 118K|00:00:00.16 | 39 | | | |
|* 6 | TABLE ACCESS FULL | CHANNELS | 1 | 1 | 1 |00:00:00.01 | 6 | | | |
| 7 | PARTITION RANGE ALL | | 1 | | 118K|00:00:00.10 | 33 | | | |
| 8 | BITMAP CONVERSION TO ROWIDS | | 28 | | 118K|00:00:00.04 | 33 | | | |
|* 9 | BITMAP INDEX SINGLE VALUE | SALES_CHANNEL_BIX | 28 | | 20 |00:00:00.01 | 33 | | | |
| 10 | TABLE ACCESS BY LOCAL INDEX ROWID| SALES | 118K| 229K| 118K|00:00:00.24 | 3655 | | | |
-----------------------------------------------------------------------------------------------------------------------------------------------
(참고) Bree 인덱스로도 ST 기능을 사용할 수 있다. ( 단. _b_tree_bitmap_plans = true )
(참고) 바인드 변수 사용시
SQL> ALTER SESSION SET "star_transformation_enabled" = TRUE;
Statement Processed.
SQL> SELECT /*+ gather_plan_statistics */ p.prod_id
,c.channel_id
,SUM(quantity_sold) AS qs
,SUM(amount_sold) AS amt
FROM sales s, channels c, products p
WHERE s.channel_id = c.channel_id
AND c.channel_desc = :A --'Internet'
AND s.prod_id = p.prod_id
AND p.prod_category_desc = :B --'Photo'
GROUP BY p.prod_id, c.channel_id;
PROD_ID CHANNEL_ID QS AMT
------- ----------- ----------- -----------
136 4 124 4767.1
138 4 543 71203.21
137 4 1701 89044.53
13 4 1424 1376202.76
135 4 1926 98759.33
17 4 755 930450.94
134 4 1037 22091.54
132 4 1590 41347
133 4 2291 72670.59
131 4 1832 36130.95
10 rows selected.
SQL> select * from table( dbms_xplan.display_cursor( null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 3jaqhhxup0kjm, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics */ p.prod_id ,c.channel_id
,SUM(quantity_sold) AS qs ,SUM(amount_sold) AS
amt FROM sales s, channels c, products p WHERE s.channel_id =
c.channel_id AND c.channel_desc = :A --'Internet' AND
s.prod_id = p.prod_id AND p.prod_category_desc = :B --'Photo'
GROUP BY p.prod_id, c.channel_id
Plan hash value: 2213333095
-----------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
-----------------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 10 |00:00:00.46 | 3700 | | | |
| 1 | HASH GROUP BY | | 1 | 8 | 10 |00:00:00.46 | 3700 | 830K| 830K| 2004K (0)|
|* 2 | HASH JOIN | | 1 | 31904 | 13223 |00:00:00.29 | 3700 | 1517K| 1517K| 1152K (0)|
|* 3 | TABLE ACCESS FULL | PRODUCTS | 1 | 10 | 10 |00:00:00.01 | 6 | | | |
| 4 | NESTED LOOPS | | 1 | | 118K|00:00:00.56 | 3694 | | | |
| 5 | NESTED LOOPS | | 1 | 229K| 118K|00:00:00.16 | 39 | | | |
|* 6 | TABLE ACCESS FULL | CHANNELS | 1 | 1 | 1 |00:00:00.01 | 6 | | | |
| 7 | PARTITION RANGE ALL | | 1 | | 118K|00:00:00.10 | 33 | | | |
| 8 | BITMAP CONVERSION TO ROWIDS | | 28 | | 118K|00:00:00.04 | 33 | | | |
|* 9 | BITMAP INDEX SINGLE VALUE | SALES_CHANNEL_BIX | 28 | | 20 |00:00:00.01 | 33 | | | |
| 10 | TABLE ACCESS BY LOCAL INDEX ROWID| SALES | 118K| 229K| 118K|00:00:00.24 | 3655 | | | |
-----------------------------------------------------------------------------------------------------------------------------------------------
SELECT /*+ gather_plan_statistics */ p.prod_id
,c.channel_id
,SUM(quantity_sold) AS qs
,SUM(amount_sold) AS amt
FROM sales s, channels c, products p
WHERE s.channel_id = c.channel_id
AND c.channel_desc ='Internet'
AND s.prod_id = p.prod_id
AND p.prod_category_desc ='Photo'
AND s.channel_id = ANY ( SELECT c1.channel_id
FROM channels c1
WHERE c1.channel_desc ='Internet')
AND s.prod_id = ANY ( SELECT p1.prod_id
FROM products p1
WHERE p1.prod_category_desc ='Photo')
GROUP BY p.prod_id, c.channel_id ;
SELECT p.prod_id, c.channel_id,
SUM (quantity_sold) AS qs ,
SUM (amount_sold) AS arnt
FROM sales s ,channels c , products p
WHERE s.channel_id = c.channel_id
AND c.channel_desc = 'Internet'
AND s.prod_id = p. prod_id
AND p.prod_category_desc = 'Photo'
AND s.channel_id = ANY ( SELECT cl.channel_id
FROM channels cl WHERE cl.channel_desc = 'Internet' )
AND s.prod_id = ANY ( SELECT pl.prod_id
FROM products pl WHERE pl.prod_category_desc = 'Photo' )
GROUP BY p.prod_id, c.channel_id;
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.2.0.3')
DB_VERSION('11.2.0.3')
OPT_PARAM('star_transformation_enabled' 'true')
OPT_PARAM('optimizer_index_cost_adj' 20)
ALL_ROWS
OUTLINE_LEAF(@"SEL$D750A531")
OUTLINE_LEAF(@"SEL$1898F719")
OUTLINE_LEAF(@"SEL$26AA4408")
TABLE_LOOKUP_BY_NL(@"SEL$5208623C" "S"@"SEL$1")
OUTLINE_LEAF(@"SEL$45464E50")
OUTLINE(@"SEL$1")
OUTLINE(@"SEL$5208623C")
STAR_TRANSFORMATION(@"SEL$1" "S"@"SEL$1" SUBQUERIES(("C"@"SEL$1") ("P"@"SEL$1")))
FULL(@"SEL$45464E50" "C"@"SEL$1")
FULL(@"SEL$45464E50" "P"@"SEL$1")
NO_ACCESS(@"SEL$45464E50" "VW_ST_34C376F1"@"SEL$45464E50")
LEADING(@"SEL$45464E50" "C"@"SEL$1" "P"@"SEL$1" "VW_ST_34C376F1"@"SEL$45464E50")
USE_MERGE_CARTESIAN(@"SEL$45464E50" "P"@"SEL$1")
USE_HASH(@"SEL$45464E50" "VW_ST_34C376F1"@"SEL$45464E50")
USE_HASH_AGGREGATION(@"SEL$45464E50")
BITMAP_TREE(@"SEL$26AA4408" "S"@"SEL$1" AND(("SALES"."PROD_ID") ("SALES"."CHANNEL_ID")))
ROWID(@"SEL$26AA4408" "SYS_CP_S"@"SEL$26AA4408")
LEADING(@"SEL$26AA4408" "S"@"SEL$1" "SYS_CP_S"@"SEL$26AA4408")
USE_NL(@"SEL$26AA4408" "SYS_CP_S"@"SEL$26AA4408")
FULL(@"SEL$1898F719" "P"@"SEL$1898F719")
SEMIJOIN_DRIVER(@"SEL$1898F719")
FULL(@"SEL$D750A531" "C"@"SEL$D750A531")
SEMIJOIN_DRIVER(@"SEL$D750A531")
END_OUTLINE_DATA
*/
ST: Updated best state, Cost = 116.38
ST: Generating directive for second pass
ST: Fact Table Candidate: PRODUCTS[P] discarded since fact table joined to less than 2 tables
ST: Fact Table Candidate: CHANNELS[C] discarded since fact table joined to less than 2 tables
ST: Fact Table Candidate: SALES[S] valid
ST: Finding dimensions of SALES[S]
ST: Dimension Table Candidate: PRODUCTS[P], Star cols: [PROD_ID-PROD_ID]
ST: Valid Dimension Table: PRODUCTS[P], sel = 0.013889
ST: Dimension Table Candidate: CHANNELS[C], Star cols: [CHANNEL_ID-CHANNEL_ID]
ST: Valid Dimension Table: CHANNELS[C], sel = 0.200000
ST: Determining efficient subqueries for SALES[S]
Registered qb: SEL$D750A531 0x10a28110 (STAR TRANSFORM SUBQUERY SEL$1)
...
---------------------
QUERY BLOCK SIGNATURE
---------------------
signature (): qb_name=SEL$D750A531 nbfros=1 flg=0
fro(0): flg=4 objn=153706 hint_alias="C"@"SEL$D750A531"
ST: Subquery text:******* UNPARSED QUERY IS *******
SELECT "C"."CHANNEL_ID" "ITEM_1" FROM "TLO"."CHANNELS" "C" WHERE "C"."CHANNEL_DESC"='Internet'
ST: Begin: find best directive for query block SEL$D750A531 (#2)
ST: not valid since query block has less than 3 tables
ST: no directive since Not valid
ST: End: finding best directive for query block SEL$D750A531 (#2)
ST: JBE not valid since dimension column referenced outside
ST: No partition pruning
ST: TTT not valid based on cost since small dimension
ST: TTT not valid since cost validation failed
FPD: Considering simple filter push in query block SEL$D750A531 (#2)
"C"."CHANNEL_DESC"='Internet'
try to generate transitive predicate from check constraints for query block SEL$D750A531 (#2)
finally: "C"."CHANNEL_DESC"='Internet'
...
---------------------
QUERY BLOCK SIGNATURE
---------------------
signature (): qb_name=SEL$1898F719 nbfros=1 flg=0
fro(0): flg=4 objn=153736 hint_alias="P"@"SEL$1898F719"
ST: Subquery text:******* UNPARSED QUERY IS *******
SELECT "P"."PROD_ID" "ITEM_1" FROM "TLO"."PRODUCTS" "P" WHERE "P"."PROD_CATEGORY_DESC"='Photo'
ST: Begin: find best directive for query block SEL$1898F719 (#3)
ST: not valid since query block has less than 3 tables
ST: no directive since Not valid
ST: End: finding best directive for query block SEL$1898F719 (#3)
ST: JBE not valid since dimension column referenced outside
ST: No partition pruning
ST: TTT not valid based on cost since small dimension
ST: TTT not valid since cost validation failed
FPD: Considering simple filter push in query block SEL$1898F719 (#3)
"P"."PROD_CATEGORY_DESC"='Photo'
try to generate transitive predicate from check constraints for query block SEL$1898F719 (#3)
finally: "P"."PROD_CATEGORY_DESC"='Photo'
: Start Transformation 적용 시 Cost Based 환경을 이용하라.
_optimizer_use_cbqt_transformation = true ( Default ) , False 시,예전의 불완전한 ST 기능으로 돌아감
Outline Data:
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.2.0.3')
DB_VERSION('11.2.0.3')
OPT_PARAM('star_transformation_enabled' 'true')
OPT_PARAM('optimizer_index_cost_adj' 20)
ALL_ROWS
OUTLINE_LEAF(@"SEL$D750A531")
OUTLINE_LEAF(@"SEL$1898F719")
OUTLINE_LEAF(@"SEL$26AA4408")
TABLE_LOOKUP_BY_NL(@"SEL$5208623C" "S"@"SEL$1")
OUTLINE_LEAF(@"SEL$45464E50")
OUTLINE(@"SEL$1")
OUTLINE(@"SEL$5208623C")
STAR_TRANSFORMATION(@"SEL$1" "S"@"SEL$1" SUBQUERIES(("C"@"SEL$1") ("P"@"SEL$1")))
FULL(@"SEL$45464E50" "C"@"SEL$1")
FULL(@"SEL$45464E50" "P"@"SEL$1")
NO_ACCESS(@"SEL$45464E50" "VW_ST_34C376F1"@"SEL$45464E50")
LEADING(@"SEL$45464E50" "C"@"SEL$1" "P"@"SEL$1" "VW_ST_34C376F1"@"SEL$45464E50")
USE_MERGE_CARTESIAN(@"SEL$45464E50" "P"@"SEL$1")
USE_HASH(@"SEL$45464E50" "VW_ST_34C376F1"@"SEL$45464E50")
USE_HASH_AGGREGATION(@"SEL$45464E50")
BITMAP_TREE(@"SEL$26AA4408" "S"@"SEL$1" AND(("SALES"."CHANNEL_ID") ("SALES"."PROD_ID")))
ROWID(@"SEL$26AA4408" "SYS_CP_S"@"SEL$26AA4408")
LEADING(@"SEL$26AA4408" "S"@"SEL$1" "SYS_CP_S"@"SEL$26AA4408")
USE_NL(@"SEL$26AA4408" "SYS_CP_S"@"SEL$26AA4408")
FULL(@"SEL$1898F719" "P"@"SEL$1898F719")
SEMIJOIN_DRIVER(@"SEL$1898F719")
FULL(@"SEL$D750A531" "C"@"SEL$D750A531")
SEMIJOIN_DRIVER(@"SEL$D750A531")
END_OUTLINE_DATA
*/
***********************************
ST: Star Transformation
***********************************
ST: Query in kkqctTD:******* UNPARSED QUERY IS *******
SELECT "P"."PROD_ID" "PROD_ID","C"."CHANNEL_ID" "CHANNEL_ID",SUM("S"."QUANTITY_SOLD") "QS",SUM("S"."AMOUNT_SOLD") "AMT" FROM "TLO"."
SALES" "S","TLO"."CHANNELS" "C","TLO"."PRODUCTS" "P" WHERE "S"."CHANNEL_ID"="C"."CHANNEL_ID" AND "C"."CHANNEL_DESC"='Internet' AND "
S"."PROD_ID"="P"."PROD_ID" AND "P"."PROD_CATEGORY_DESC"='Photo' GROUP BY "P"."PROD_ID","C"."CHANNEL_ID"
ST: Begin: find best directive for query block SEL$1 (#1)
discarded since not big enough
ST: Using search type: two pass
ST: Generating directive for first pass
ST: Starting iteration 1, directive =
{Not Transformed}
... 중략
ST: Costing transformed query.
kkoqbc: optimizing query block SEL$1 (#1)
ST: Updated best state, Cost = 568.58
ST: Generating directive for second pass
ST: Fact Table Candidate: PRODUCTS[P] discarded since fact table joined to less than 2 tables
ST: Fact Table Candidate: CHANNELS[C] discarded since fact table joined to less than 2 tables
ST: Fact Table Candidate: SALES[S] valid
ST: Finding dimensions of SALES[S]
ST: Dimension Table Candidate: PRODUCTS[P], Star cols: [PROD_ID-PROD_ID]
ST: Valid Dimension Table: PRODUCTS[P], sel = 0.138889
ST: Dimension Table Candidate: CHANNELS[C], Star cols: [CHANNEL_ID-CHANNEL_ID]
ST: Valid Dimension Table: CHANNELS[C], sel = 0.200000
ST: Determining efficient subqueries for SALES[S]
Registered qb: SEL$D750A531 0x10a29190 (STAR TRANSFORM SUBQUERY SEL$1)
---------------------
QUERY BLOCK SIGNATURE
---------------------
signature (): qb_name=SEL$D750A531 nbfros=1 flg=0
fro(0): flg=4 objn=153706 hint_alias="C"@"SEL$D750A531"
ST: Subquery text:******* UNPARSED QUERY IS *******
SELECT "C"."CHANNEL_ID" "ITEM_1" FROM "TLO"."CHANNELS" "C" WHERE "C"."CHANNEL_DESC"='Internet'
ST: Begin: find best directive for query block SEL$D750A531 (#2)
ST: not valid since query block has less than 3 tables
ST: no directive since Not valid
ST: End: finding best directive for query block SEL$D750A531 (#2)
ST: JBE not valid since dimension column referenced outside
ST: No partition pruning
ST: TTT not valid based on cost since small dimension
ST: TTT not valid since cost validation failed
FPD: Considering simple filter push in query block SEL$D750A531 (#2)
"C"."CHANNEL_DESC"='Internet'
try to generate transitive predicate from check constraints for query block SEL$D750A531 (#2)
finally: "C"."CHANNEL_DESC"='Internet'
CBQT: Looking for cost annotations for query block SEL$D750A531, key = SEL$D750A531_00002000_0
CBQT: Could not find stored cost annotations.
kkoqbc: optimizing query block SEL$D750A531 (#2)
.. 중간 생략
Registered qb: SEL$1898F719 0x10a40578 (STAR TRANSFORM SUBQUERY SEL$1)
---------------------
QUERY BLOCK SIGNATURE
---------------------
signature (): qb_name=SEL$1898F719 nbfros=1 flg=0
fro(0): flg=4 objn=153736 hint_alias="P"@"SEL$1898F719"
ST: Subquery text:******* UNPARSED QUERY IS *******
SELECT "P"."PROD_ID" "ITEM_1" FROM "TLO"."PRODUCTS" "P" WHERE "P"."PROD_CATEGORY_DESC"='Photo'
..중략
kkoqbc: optimizing query block SEL$1898F719 (#3)
ST: fact qbc text******* UNPARSED QUERY IS *******
SELECT "P"."PROD_ID" "PROD_ID","C"."CHANNEL_ID" "CHANNEL_ID",SUM("S"."QUANTITY_SOLD") "QS",SUM("S"."AMOUNT_SOLD") "AMT" FROM "TLO"."
SALES" "S","TLO"."CHANNELS" "C","TLO"."PRODUCTS" "P" WHERE "S"."PROD_ID"=ANY (SELECT "P"."PROD_ID" "ITEM_1" FROM "TLO"."PRODUCTS" "P
" WHERE "P"."PROD_CATEGORY_DESC"='Photo') AND "S"."CHANNEL_ID"=ANY (SELECT "C"."CHANNEL_ID" "ITEM_1" FROM "TLO"."CHANNELS" "C" WHERE
"C"."CHANNEL_DESC"='Internet') AND "S"."CHANNEL_ID"="C"."CHANNEL_ID" AND "C"."CHANNEL_DESC"='Internet' AND "S"."PROD_ID"="P"."PROD_
ID" AND "P"."PROD_CATEGORY_DESC"='Photo' GROUP BY "P"."PROD_ID","C"."CHANNEL_ID"
ST: Starting iteration 2, directive =
FACT - SALES[S] has no join index, is not on right of NL, index only check is not ok
SUBQUERY - TRIED, USED, DIM FROS - CHANNELS[C],
SUBQUERY - TRIED, USED, DIM FROS - PRODUCTS[P],
ST: Query before star xformation:******* UNPARSED QUERY IS *******
SELECT "P"."PROD_ID" "PROD_ID","C"."CHANNEL_ID" "CHANNEL_ID",SUM("S"."QUANTITY_SOLD") "QS",SUM("S"."AMOUNT_SOLD") "AMT" FROM "TLO"."
..중간생략
ST: Subquery text:******* UNPARSED QUERY IS *******
SELECT "C"."CHANNEL_ID" "ITEM_1" FROM "TLO"."CHANNELS" "C" WHERE "C"."CHANNEL_DESC"='Internet'
Registered qb: SEL$D750A531 0x10a80da0 (COPY SEL$D750A531)
..중간생략
Registered qb: SEL$5208623C 0x10a61480 (STAR TRANSFORM SEL$1; SEL$1; "S"@"SEL$1" LIST)
ST: Query after star xformation:******* UNPARSED QUERY IS *******
SELECT "P"."PROD_ID" "PROD_ID","C"."CHANNEL_ID" "CHANNEL_ID",SUM("S"."QUANTITY_SOLD") "QS",SUM("S"."AMOUNT_SOLD") "AMT" FROM "TLO"."
SALES" "S","TLO"."CHANNELS" "C","TLO"."PRODUCTS" "P" WHERE "S"."PROD_ID"=ANY (SELECT /*+ SEMIJOIN_DRIVER */ "P"."PROD_ID" "ITEM_1" F
ROM "TLO"."PRODUCTS" "P" WHERE "P"."PROD_CATEGORY_DESC"='Photo') AND "S"."CHANNEL_ID"=ANY (SELECT /*+ SEMIJOIN_DRIVER */ "C"."CHANNE
L_ID" "ITEM_1" FROM "TLO"."CHANNELS" "C" WHERE "C"."CHANNEL_DESC"='Internet') AND "S"."CHANNEL_ID"="C"."CHANNEL_ID" AND "C"."CHANNEL
_DESC"='Internet' AND "S"."PROD_ID"="P"."PROD_ID" AND "P"."PROD_CATEGORY_DESC"='Photo' GROUP BY "P"."PROD_ID","C"."CHANNEL_ID"
... 중간생략
kkoqbc: optimizing query block SEL$D750A531 (#4)
ST: Updated best state, Cost = 267.92
..중간생략
ST: Best state: Total iteration 2, directive =
FACT - <unnamed>[] has no join index, is not on right of NL, index only check is ok 책:<SALES>[S]
SUBQUERY - TRIED, USED, DIM FROS - CHANNELS[C],
SUBQUERY - TRIED, USED, DIM FROS - PRODUCTS[P],
ST: End: finding best directive for query block SEL$45464E50 (#1)
REWRITE/NO_REWRITE
SQL> SELECT /*+ gather_plan_statistics 01 */ a.department_id, b.department_name, SUM(a.salary) salary_sum
2 FROM employee a, department b
3 WHERE a.department_id = b.department_id
4 AND b.department_id = 10
5 GROUP BY a.department_id, b.department_name ;
DEPARTMENT_ID DEPARTMENT_NAME SALARY_SUM
------------- ------------------------------ ----------
10 Administration 4400
SQL> select * from table( dbms_xplan.display_cursor( null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 324wrdma2txaw, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics 01 */ a.department_id,
b.department_name, SUM(a.salary) salary_sum FROM employee a,
department b WHERE a.department_id = b.department_id AND
b.department_id = 10 GROUP BY a.department_id, b.department_name
Plan hash value: 2219879030
--------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
--------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 3 |
| 1 | MAT_VIEW REWRITE ACCESS BY INDEX ROWID| DEPT_SAL | 1 | 1 | 1 |00:00:00.01 | 3 |
|* 2 | INDEX RANGE SCAN | IDX_DEPT_SAL_01 | 1 | 1 | 1 |00:00:00.01 | 2 |
--------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("DEPT_SAL"."DEPARTMENT_ID"=10)
22 rows selected.
SQL> SELECT department_id, department_name, salary_sum
FROM dept_sal
WHERE department_id =10
Outline Data:
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.2.0.3')
DB_VERSION('11.2.0.3')
OPT_PARAM('optimizer_index_cost_adj' 20)
ALL_ROWS
OUTLINE_LEAF(@"SEL$01E878FB")
REWRITE(@"SEL$240F160A" "DEPT_SAL")
OUTLINE(@"SEL$240F160A")
REWRITE(@"SEL$1" "DEPT_SAL")
OUTLINE(@"SEL$1")
INDEX_RS_ASC(@"SEL$01E878FB" "DEPT_SAL"@"SEL$7991DADF" ("DEPT_SAL"."DEPARTMENT_ID"))
END_OUTLINE_DATA
*/
Copy query block qb# -1 (<unnamed>) : SELECT * FROM "TLO"."DEPT_SAL"
Registered qb: SEL$7991DADF 0x109ab640 (PARSER)
---------------------
QUERY BLOCK SIGNATURE
---------------------
signature (): qb_name=SEL$7991DADF nbfros=1 flg=0
fro(0): flg=4 objn=154046 hint_alias="DEPT_SAL"@"SEL$7991DADF"
Registered qb: SEL$240F160A 0x10936a80 (MV REWRITE SEL$1; SEL$1; DEPT_SAL)
---------------------
QUERY BLOCK SIGNATURE
---------------------
signature (): qb_name=SEL$240F160A nbfros=1 flg=0
fro(0): flg=0 objn=154046 hint_alias="DEPT_SAL"@"SEL$7991DADF"
OJE: Begin: find best directive for query block SEL$240F160A (#0)
OJE: End: finding best directive for query block SEL$240F160A (#0)
query block SEL$1 transformed to SEL$240F160A (#0)
Considering Query Transformations on query block SEL$240F160A (#0)
**************************
Query transformations (QT)
**************************
**************************
Predicate Move-Around (PM)
**************************
PM: PM bypassed: Outer query contains no views.
PM: PM bypassed: Outer query contains no views.
Registered qb: SEL$01E878FB 0x10936a80 (MV REWRITE SEL$240F160A; SEL$240F160A; DEPT_SAL)
Heuristic :CSE, OBYE, DE, SVM, JE, CNT, SSU, PM, FPD 등
************************************
Cost-based predicate pushdown (JPPD)
************************************
kkqctdrvTD-start on query block SEL$01E878FB (#1)
kkqctdrvTD-start: :
call(in-use=27904, alloc=49080), compile(in-use=128656, alloc=132680), execution(in-use=4440, alloc=8088)
kkqctdrvTD-cleanup: transform(in-use=0, alloc=0) :
call(in-use=27904, alloc=49080), compile(in-use=129344, alloc=132680), execution(in-use=4440, alloc=8088)
kkqctdrvTD-end:
call(in-use=27904, alloc=49080), compile(in-use=129744, alloc=132680), execution(in-use=4440, alloc=8088)
JPPD: Applying transformation directives
query block SEL$240F160A transformed to SEL$01E878FB (#1)
FPD: Considering simple filter push in query block SEL$01E878FB (#1)
"DEPT_SAL"."DEPARTMENT_ID"=10
try to generate transitive predicate from check constraints for query block SEL$01E878FB (#1)
finally: "DEPT_SAL"."DEPARTMENT_ID"=10
Final query after transformations:******* UNPARSED QUERY IS *******
SELECT "DEPT_SAL"."DEPARTMENT_ID" "DEPARTMENT_ID","DEPT_SAL"."DEPARTMENT_NAME" "DEPARTMENT_NAME","DEPT_SAL"."SALARY_SUM" "SALARY_SUM
" FROM "TLO"."DEPT_SAL" "DEPT_SAL" WHERE "DEPT_SAL"."DEPARTMENT_ID"=10
kkoqbc: optimizing query block SEL$01E878FB (#1)
*********************************
Number of join permutations tried: 1
*********************************
Enumerating distribution method (advanced)
Trying or-Expansion on query block SEL$01E878FB (#1)
Transfer Optimizer annotations for query block SEL$01E878FB (#1)
id=0 frofkks[i] (index start key) predicate="DEPT_SAL"."DEPARTMENT_ID"=10
id=0 frofkke[i] (index stop key) predicate="DEPT_SAL"."DEPARTMENT_ID"=10
Final cost for query block SEL$01E878FB (#1) - All Rows Plan:
Best join order: 1
Cost: 1.0003 Degree: 1 Card: 1.0000 Bytes: 19
Resc: 1.0003 Resc_io: 1.0000 Resc_cpu: 2927
Resp: 1.0003 Resp_io: 1.0000 Resc_cpu: 2927
Copy query block qb# -1 (<unnamed>) : SELECT /*+ 10053 01 */ a.department_id, b.department_name, SUM(a.salary) salary_sum
FROM employee a, department b
WHERE a.department_id = b.department_id
AND b.department_id = 10
GROUP BY a.department_id, b.department_name
Considering Query Transformations on query block SEL$1 (#0)
**************************
Query transformations (QT)
**************************
CBQT: Validity checks passed for 2du4w64ux11ky.
CSE: Considering common sub-expression elimination in query block SEL$1 (#0)
*********************************
Number of join permutations tried: 1
*********************************
Consider using bloom filter between B[DEPARTMENT] and A[EMPLOYEE] with ??
kkoBloomFilter: join ndv:0 reduction:1.000000 (limit:0.500000) rejected because not a hash join
Enumerating distribution method (advanced)
--- Distribution method for
join between B[DEPARTMENT](serial) and A[EMPLOYEE](serial); jm = 12; right side access path = IndexRange
---- NLJ default -> BROADCAST-LEFT
(newjo-save) [0 1 ]
SORT ressource Sort statistics
Sort width: 598 Area size: 536576 Max Area size: 104857600
Degree: 1
Blocks to Sort: 1 Row size: 36 Total Rows: 10
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 8863270
Total Temp space used: 0
Trying or-Expansion on query block SEL$1 (#1)
Transfer Optimizer annotations for query block SEL$1 (#1)
Final cost for query block SEL$1 (#1) - All Rows Plan:
Best join order: 1
Cost: 2.0005 Degree: 1 Card: 10.0000 Bytes: 230
-- Bitmap Join 인덱스 생성
CREATE BITMAP INDEX emp_join_idx_01 ON employee ( d.location_id)
FROM employee e, department d
WHERE e.department_id = d.department_id ;
SQL> SELECT /*+ gather_plan_statistics INDEX(e emp_join_idx_01) */ COUNT(*)
2 FROM employee e, department d
3 WHERE e.department_id = d.department_id
4 AND d.location_id = 1700 ;
COUNT(*)
----------
18
SQL> select * from table( dbms_xplan.display_cursor( null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 7ajwk26jq24mz, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics INDEX(e emp_join_idx_01) */ COUNT(*)
FROM employee e, department d WHERE e.department_id =
d.department_id AND d.location_id = 1700
Plan hash value: 518796859
---------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
---------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 1 |
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.01 | 1 |
| 2 | BITMAP CONVERSION COUNT | | 1 | 15 | 1 |00:00:00.01 | 1 |
|* 3 | BITMAP INDEX SINGLE VALUE| EMP_JOIN_IDX_01 | 1 | | 1 |00:00:00.01 | 1 |
---------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("E"."SYS_NC00012$"=1700)
22 rows selected.
Outline Data:
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.2.0.3')
DB_VERSION('11.2.0.3')
OPT_PARAM('optimizer_index_cost_adj' 20)
ALL_ROWS
OUTLINE_LEAF(@"SEL$DBFB62D6")
ELIMINATE_JOIN(@"SEL$1" "D"@"SEL$1")
OUTLINE(@"SEL$1")
BITMAP_TREE(@"SEL$1" "E"@"SEL$1" AND(("DEPARTMENT"."LOCATION_ID")))
END_OUTLINE_DATA
*/
***************************************
OST: STAR TRANSFORMATION PLANS
***************************************
Best join order so far: 2
Marked for join-back elimination: "D"@"SEL$1"
Join order[1]: EMPLOYEE[E]#0
***********************
Best so far: Table#: 0 cost: 1.0002 card: 15.2857 bytes: 45
***********************
OST: oldrsc = 2.500834, oldcst = 2.500834, rsc = 1.000165, cst = 1.000165, minRatio = 0
Registered qb: SEL$DBFB62D6 0x10936a80 (BITMAP JOIN INDEX JOINBACK ELIMINATION SEL$1; SEL$1; "D"@"SEL$1")
---------------------
QUERY BLOCK SIGNATURE
---------------------
signature (): qb_name=SEL$DBFB62D6 nbfros=1 flg=0
fro(0): flg=0 objn=153717 hint_alias="E"@"SEL$1"
OST: ST plan accepted
SQL> SELECT /*+ gather_plan_statistics INDEX(e emp_join_idx_01) */ d.location_id, COUNT(*)
2 FROM employee e, department d
3 WHERE e.department_id = d.department_id
4 AND d.location_id = 1700
5 GROUP BY d.location_id ;
LOCATION_ID COUNT(*)
----------- ----------
1700 18
SQL> select * from table( dbms_xplan.display_cursor( null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------
SQL_ID 8m4602a0tphbz, child number 0
-------------------------------------
SELECT /*+ gather_plan_statistics INDEX(e emp_join_idx_01) */
d.location_id, COUNT(*) FROM employee e, department d WHERE
e.department_id = d.department_id AND d.location_id = 1700 GROUP BY
d.location_id
Plan hash value: 4010296542
----------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
----------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 4 | | | |
| 1 | SORT GROUP BY NOSORT | | 1 | 1 | 1 |00:00:00.01 | 4 | | | |
|* 2 | HASH JOIN | | 1 | 5 | 18 |00:00:00.01 | 4 | 1517K| 1517K| 1003K (0)|
| 3 | TABLE ACCESS BY INDEX ROWID | EMPLOYEE | 1 | 15 | 18 |00:00:00.01 | 2 | | | |
| 4 | BITMAP CONVERSION TO ROWIDS| | 1 | | 18 |00:00:00.01 | 1 | | | |
|* 5 | BITMAP INDEX SINGLE VALUE | EMP_JOIN_IDX_01 | 1 | | 1 |00:00:00.01 | 1 | | | |
| 6 | TABLE ACCESS BY INDEX ROWID | DEPARTMENT | 1 | 4 | 21 |00:00:00.01 | 2 | | | |
|* 7 | INDEX RANGE SCAN | DEPT_LOCATION_IX | 1 | 4 | 21 |00:00:00.01 | 1 | | | |
----------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("E"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")
5 - access("E"."SYS_NC00012$"=1700)
7 - access("D"."LOCATION_ID"=1700)
29 rows selected