트러블슈팅 오라클 퍼포먼스 2판 (2017년)
쿼리 변환 - 서브쿼리 통합 (휴리스틱 기반) 0 0 44,960

by 구루비스터디 쿼리변환 서브쿼리통합 휴리스틱기반 [2023.09.08]


  • 휴리스틱 기반의 쿼리 변환 : 특정 조건을 충족시키는 경우 적용
  • 비용 기반의 쿼리 변환 : 비용 추정기가 산출한 비용에 근거하여, 원래 실행 계획보다 더 낮은 비용의 실행 계획이 생성될 경우 적용


쿼리 변환 - 서브쿼리 통합 (휴리스틱 기반)



*****************************
Cost-Based Subquery Unnesting
*****************************
SU: Unnesting query blocks in query block SEL$1 (#1) that are valid to unnest.
Subquery Unnesting on query block SEL$1 (#1)SU: Performing unnesting that does not require costing.
SU: Considering subquery unnest on query block SEL$1 (#1).
SU:   Checking validity of unnesting subquery SEL$ACD206C8 (#2)
SU:   Passed validity checks.
SU:   Transforming EXISTS subquery to a join.
Registered qb: SEL$82F4A621 0x715d9c90 (SUBQUERY UNNEST SEL$1; SEL$ACD206C8)
---------------------
QUERY BLOCK SIGNATURE
---------------------
  signature (): qb_name=SEL$82F4A621 nbfros=2 flg=0
    fro(0): flg=0 objn=148979 hint_alias="T1"@"SEL$1"
    fro(1): flg=0 objn=148981 hint_alias="T2"@"SEL$2"

*******************************
Cost-Based Complex View Merging
*******************************
CVM: Finding query blocks in query block SEL$82F4A621 (#1) that are valid to merge.
OJE: Begin: find best directive for query block SEL$82F4A621 (#1)
OJE: End: finding best directive for query block SEL$82F4A621 (#1)
kkqctdrvTD-cleanup: transform(in-use=5304, alloc=8136) :
    call(in-use=3784, alloc=16344), compile(in-use=151256, alloc=177944), execution(in-use=213368, alloc=215968)

kkqctdrvTD-end:
    call(in-use=3784, alloc=16344), compile(in-use=143496, alloc=177944), execution(in-use=213368, alloc=215968)

SU:   Transforming EXISTS subquery to a join.
SJC: Considering set-join conversion in query block SEL$82F4A621 (#1)
*************************
Set-Join Conversion (SJC)
*************************
SJC: not performed
OJE: Begin: find best directive for query block SEL$82F4A621 (#1)
OJE: End: finding best directive for query block SEL$82F4A621 (#1)
JE:   Considering Join Elimination on query block SEL$82F4A621 (#1)
*************************
Join Elimination (JE)
*************************
SQL:******* UNPARSED QUERY IS *******
SELECT "T1"."ID" "ID","T1"."N" "N","T1"."PAD" "PAD" FROM "CHRIS"."T2" "T2","CHRIS"."T1" "T1" WHERE "T2"."ID"="T1"."ID" AND ("T2"."N">10 OR "T2"."N"<100)
JE:   cfro: T2 objn:148979 col#:1 dfro:T1 dcol#:1
JE:   cfro: T2 objn:148979 col#:1 dfro:T1 dcol#:1
JE:   cfro: T1 objn:148981 col#:1 dfro:T2 dcol#:1
SQL:******* UNPARSED QUERY IS *******
SELECT "T1"."ID" "ID","T1"."N" "N","T1"."PAD" "PAD" FROM "CHRIS"."T2" "T2","CHRIS"."T1" "T1" WHERE "T2"."ID"="T1"."ID" AND ("T2"."N">10 OR "T2"."N"<100)
Query block SEL$82F4A621 (#1) unchanged
PM: Considering predicate move-around in query block SEL$82F4A621 (#1)
**************************
Predicate Move-Around (PM)
**************************
PM:     PM bypassed: Outer query contains no views.
PM:     PM bypassed: Outer query contains no views.
kkqctdrvTD-start on query block SEL$82F4A621 (#1)
kkqctdrvTD-start: :
    call(in-use=4760, alloc=16344), compile(in-use=144368, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-cleanup: transform(in-use=0, alloc=0) :
    call(in-use=4760, alloc=16344), compile(in-use=145160, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-end:
    call(in-use=4760, alloc=16344), compile(in-use=145640, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-start on query block SEL$82F4A621 (#1)
kkqctdrvTD-start: :
    call(in-use=4760, alloc=16344), compile(in-use=145640, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-cleanup: transform(in-use=0, alloc=0) :
    call(in-use=4760, alloc=16344), compile(in-use=146408, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-end:
    call(in-use=4760, alloc=16344), compile(in-use=146888, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-start on query block SEL$82F4A621 (#1)
kkqctdrvTD-start: :
    call(in-use=4760, alloc=16344), compile(in-use=146888, alloc=177944), execution(in-use=213408, alloc=215968)

TE: Checking validity of table expansion for query block SEL$82F4A621 (#1)
TE: Bypassed: No partitioned table in query block.
kkqctdrvTD-cleanup: transform(in-use=0, alloc=0) :
    call(in-use=4760, alloc=16344), compile(in-use=147680, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-end:
    call(in-use=4760, alloc=16344), compile(in-use=148160, alloc=177944), execution(in-use=213408, alloc=215968)

TE: Checking validity of table expansion for query block SEL$82F4A621 (#1)
TE: Bypassed: No partitioned table in query block.
ST: Query in kkqstardrv:******* UNPARSED QUERY IS *******
SELECT "T1"."ID" "ID","T1"."N" "N","T1"."PAD" "PAD" FROM "CHRIS"."T2" "T2","CHRIS"."T1" "T1" WHERE "T2"."ID"="T1"."ID" AND ("T2"."N">10 OR "T2"."N"<100)
ST: not valid since star transformation parameter is FALSE
kkqctdrvTD-start on query block SEL$82F4A621 (#1)
kkqctdrvTD-start: :
    call(in-use=4904, alloc=16344), compile(in-use=148160, alloc=177944), execution(in-use=213408, alloc=215968)

JF: Checking validity of join factorization for query block SEL$82F4A621 (#1)
JF: Bypassed: not a UNION or UNION-ALL query block.
kkqctdrvTD-cleanup: transform(in-use=0, alloc=0) :
    call(in-use=4904, alloc=16344), compile(in-use=148928, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-end:
    call(in-use=4904, alloc=16344), compile(in-use=149408, alloc=177944), execution(in-use=213408, alloc=215968)

JPPD:  Considering Cost-based predicate pushdown from query block SEL$82F4A621 (#1)
************************************
Cost-based predicate pushdown (JPPD)
************************************
kkqctdrvTD-start on query block SEL$82F4A621 (#1)
kkqctdrvTD-start: :
    call(in-use=4904, alloc=16344), compile(in-use=149408, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-cleanup: transform(in-use=0, alloc=0) :
    call(in-use=4904, alloc=16344), compile(in-use=150176, alloc=177944), execution(in-use=213408, alloc=215968)

kkqctdrvTD-end:
    call(in-use=4904, alloc=16344), compile(in-use=150656, alloc=177944), execution(in-use=213408, alloc=215968)

JPPD: Applying transformation directives
query block SEL$1 transformed to SEL$82F4A621 (#1)
FPD: Considering simple filter push in query block SEL$82F4A621 (#1)
"T2"."ID"="T1"."ID" AND ("T2"."N">10 OR "T2"."N"<100)
try to generate transitive predicate from check constraints for query block SEL$82F4A621 (#1)
finally: "T2"."ID"="T1"."ID" AND ("T2"."N">10 OR "T2"."N"<100)

Final query after transformations:******* UNPARSED QUERY IS *******
SELECT "T1"."ID" "ID","T1"."N" "N","T1"."PAD" "PAD" FROM "CHRIS"."T2" "T2","CHRIS"."T1" "T1" WHERE "T2"."ID"="T1"."ID" AND ("T2"."N">10 OR "T2"."N"<100)
kkoqbc: optimizing query block SEL$82F4A621 (#1)

        :
    call(in-use=5240, alloc=16344), compile(in-use=151960, alloc=177944), execution(in-use=213408, alloc=215968)

kkoqbc-subheap (create addr=0x7f7752695618)
****************
QUERY BLOCK TEXT
****************
SELECT *
FROM t1
WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.n > 10 AND t2.id = t1.id)
OR EXISTS (SELECT 1 FROM t2 WHERE t2.n < 100 AND t2.id = t1.id)

SELECT "T1"."ID" "ID",
       "T1"."N" "N",
       "T1"."PAD" "PAD"
  FROM "CHRIS"."T2" "T2",
       "CHRIS"."T1" "T1"
 WHERE "T2"."ID"="T1"."ID"
   AND ("T2"."N">10 OR "T2"."N"<100)


"데이터베이스 스터디모임" 에서 2017년에 "전문가를 위한 트러블슈팅 오라클 퍼포먼스(Second Edition) " 도서를 스터디하면서 정리한 내용 입니다.

- 강좌 URL : http://www.gurubee.net/lecture/4364

- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^

- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입