SELECT *
FROM emp
WHERE sal > (SELECT avg(sal)
FROM emp)
SELECT c1, c2, c3
FROM SUBQUERY_T2 t2
WHERE c2 = 'A'
AND EXISTS (SELECT /*+ NO_UNNEST */ 'X'
FROM SUBQYER_T1 tw
WHERE t1.c5 = t2.c2)
SELECT /*+ QB_NQME(B)*/col1
FROM (SELECT LEVEL col1
FROM DUAL CONNECT BY LEVEL<=3) a
WHERE a.col1 IN (SELECT /*+ QB_NAME(A) */col1
FROM (SELECT LEVEL col1
FROM DUAL CONNECT BY LEVEL <=3
UNION ALL
SELECT LEVEL col1
FROM DUAL CONNECT BY LEVEL <=3
UNION ALL
SELECT LEVEL col1
FROM DUAL CONNECT BY LEVEL <=3 ) )
---------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 26 | 9 (12)| 00:00:01 |
|* 1 | HASH JOIN SEMI | | 1 | 26 | 9 (12)| 00:00:01 |
| 2 | VIEW | | 1 | 13 | 2 (0)| 00:00:01 |
|* 3 | CONNECT BY WITHOUT FILTERING | | | | | |
| 4 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 5 | VIEW | VW_NSO_1 | 3 | 39 | 6 (0)| 00:00:01 |
| 6 | VIEW | | 3 | 39 | 6 (0)| 00:00:01 |
| 7 | UNION-ALL | | | | | |
|* 8 | CONNECT BY WITHOUT FILTERING| | | | | |
| 9 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 10 | CONNECT BY WITHOUT FILTERING| | | | | |
| 11 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 12 | CONNECT BY WITHOUT FILTERING| | | | | |
| 13 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
---------------------------------------------------------------------------------------------
*QUERY BLOCK A의 결과 값
COL1 |
---|
1 |
2 |
3 |
1 |
2 |
3 |
1 |
2 |
3 |
*QUERY BLOCK B의 결과 값
COL1 |
---|
1 |
2 |
3 |
SELECT /*+ ORDERED QB_NQME(B)*/col1
FROM (SELECT LEVEL col1
FROM DUAL CONNECT BY LEVEL<=3) a
WHERE a.col1 IN (SELECT /*+ QB_NAME(A) */col1
FROM (SELECT LEVEL col1
FROM DUAL CONNECT BY LEVEL <=3
UNION ALL
SELECT LEVEL col1
FROM DUAL CONNECT BY LEVEL <=3
UNION ALL
SELECT LEVEL col1
FROM DUAL CONNECT BY LEVEL <=3 ) ) ;
----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 26 | 10 (20)| 00:00:01 |
|* 1 | HASH JOIN | | 1 | 26 | 10 (20)| 00:00:01 |
| 2 | VIEW | VW_NSO_1 | 3 | 39 | 6 (0)| 00:00:01 |
| 3 | HASH UNIQUE | | 1 | 39 | | |
| 4 | VIEW | | 3 | 39 | 6 (0)| 00:00:01 |
| 5 | UNION-ALL | | | | | |
|* 6 | CONNECT BY WITHOUT FILTERING| | | | | |
| 7 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 8 | CONNECT BY WITHOUT FILTERING| | | | | |
| 9 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 10 | CONNECT BY WITHOUT FILTERING| | | | | |
| 11 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 12 | VIEW | | 1 | 13 | 2 (0)| 00:00:01 |
|* 13 | CONNECT BY WITHOUT FILTERING | | | | | |
| 14 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
----------------------------------------------------------------------------------------------