트러블슈팅 오라클 퍼포먼스 2판 (2017년)
쿼리 변환 - 집합에서 조인으로 변환 0 0 44,267

by 구루비스터디 쿼리변환 [2023.09.08]


쿼리 변환 - 집합에서 조인으로 변환


**************************
Predicate Move-Around (PM)
**************************
PM:     PM bypassed: Outer query contains no views.
PM:     PM bypassed: Outer query contains no views.
query block SET$1 transformed to SEL$02B15F54 (#0)
FPD: Considering simple filter push in query block SEL$02B15F54 (#0)
"T1"."ID"="T2"."ID" AND "T1"."N"="T2"."N" AND "T1"."PAD"="T2"."PAD" AND "T1"."N">500 AND "T2"."PAD" LIKE 'A%'
try to generate transitive predicate from check constraints for query block SEL$02B15F54 (#0)
finally: "T1"."ID"="T2"."ID" AND "T1"."N"="T2"."N" AND "T1"."PAD"="T2"."PAD" AND "T1"."N">500 AND "T2"."PAD" LIKE 'A%' AND "T2"."N">500 AND "T1"."PAD" LIKE 'A%'

FPD:   transitive predicates are generated in query block SEL$02B15F54 (#0)
"T1"."ID"="T2"."ID" AND "T1"."N"="T2"."N" AND "T1"."PAD"="T2"."PAD" AND "T1"."N">500 AND "T2"."PAD" LIKE 'A%' AND "T2"."N">500 AND "T1"."PAD" LIKE 'A%'
apadrv-start sqlid=2629578423929517488
  :
    call(in-use=5064, alloc=16344), compile(in-use=79048, alloc=80536), execution(in-use=115616, alloc=117840)

*******************************************
Peeked values of the binds in SQL statement
*******************************************

Final query after transformations:******* UNPARSED QUERY IS *******
SELECT DISTINCT "T1"."ID" "ID","T1"."N" "N","T1"."PAD" "PAD" FROM "CHRIS"."T2" "T2","CHRIS"."T1" "T1" WHERE "T1"."ID"="T2"."ID" AND "T1"."N"="T2"."N" AND "T1"."PAD"="T2"."PAD" AND "T1"."N">500 AND "T2"."PAD" LIKE 'A%' AND "T2"."N">500 AND "T1"."PAD" LIKE 'A%'
kkoqbc: optimizing query block SEL$02B15F54 (#0)

        :
    call(in-use=5408, alloc=16344), compile(in-use=80320, alloc=80536), execution(in-use=115616, alloc=117840)

kkoqbc-subheap (create addr=0x7f70ce435618)
****************
QUERY BLOCK TEXT
****************
SELECT /*+ SET_TO_JOIN(@SET$1) */ *
FROM t1
WHERE n > 500
INTERSECT
SELECT *
FROM t2
WHERE t2.pad LIKE 'A%'

SELECT DISTINCT "T1"."ID" "ID",
       "T1"."N" "N",
       "T1"."PAD" "PAD"
  FROM "CHRIS"."T2" "T2",
       "CHRIS"."T1" "T1"
 WHERE "T1"."ID"="T2"."ID"
   AND "T1"."N"="T2"."N"
   AND "T1"."PAD"="T2"."PAD"
   AND "T1"."N">500 AND "T2"."PAD" LIKE 'A%'
   AND "T2"."N">500 AND "T1"."PAD" LIKE 'A%'

----- Current SQL Statement for this session (sql_id=28zj3nmxpmddh) -----
EXPLAIN PLAN FOR
SELECT /*+ SET_TO_JOIN(@SET$1) */ *
FROM t1
WHERE n > 500
INTERSECT
SELECT *
FROM t2
WHERE t2.pad LIKE 'A%'
sql_text_length=125
sql=EXPLAIN PLAN FOR
SELECT /*+ SET_TO_JOIN(@SET$1) */ *
FROM t1
WHERE n > 500
INTERSECT
SELECT *
FROM t2
WHERE t2.pad LIKE 'A%'
----- Explain Plan Dump -----
----- Plan Table -----

============
Plan Table
============
-------------------------------------------------+-----------------------------------+
| Id  | Operation                      | Name    | Rows  | Bytes | Cost  | Time      |
-------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT               |         |       |       |     4 |           |
| 1   |  HASH UNIQUE                   |         |     1 |   156 |     4 |  00:00:01 |
| 2   |   NESTED LOOPS                 |         |       |       |       |           |
| 3   |    NESTED LOOPS                |         |     1 |   156 |     3 |  00:00:01 |
| 4   |     TABLE ACCESS FULL          | T2      |     1 |    78 |     2 |  00:00:01 |
| 5   |     INDEX UNIQUE SCAN          | T1_PK   |     1 |       |     0 |           |
| 6   |    TABLE ACCESS BY INDEX ROWID | T1      |     1 |    78 |     1 |  00:00:01 |
-------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
4 - filter(("T2"."N">500 AND "T2"."PAD" LIKE 'A%'))
5 - access("T1"."ID"="T2"."ID")
6 - filter(("N">500 AND "T1"."PAD" LIKE 'A%' AND "T1"."N"="T2"."N" AND "T1"."PAD"="T2"."PAD"))

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

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

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

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

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