(on) Hints for Join Orders

LEADINGORDERED
{code:sqltitleBGColor=#FFFFFFtitle=!http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/img/leading_hint.gif!borderStyle=solid}
SELECT /*+ LEADING(T2) */ *
FROM T1, T2
WHERE T1.N4 = T2.N4
AND T1.N2 = 50;






















-

IdOperationNameRowsBytesCost (%CPU)Time






















-

0SELECT STATEMENT113085 (0)00:00:01
1NESTED LOOPS
2NESTED LOOPS113085 (0)00:00:01
3TABLE ACCESS FULLT2111542 (0)00:00:01
  • 4
INDEX RANGE SCANT1N2101 (0)00:00:01
  • 5
TABLE ACCESS BY INDEX ROWIDT11141 (0)00:00:01






















-

-- 추천, 조인 순서 만 지정, 방법은 별도 지정 필요 (USE_NL, USE_HASH...)
http://ukja.tistory.com/166

|{code:sql|titleBGColor=#FFFFFF|title=!http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/img/ordered_hint.gif!|borderStyle=solid}
SELECT /*+ ORDERED */ *
  FROM T1, T2
 WHERE T1.N4 = T2.N4
   AND T1.N2 = 50;

--------------------------------------------------------------------------------------
| Id  | Operation                     | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT              |      |    17 |   476 |     2   (0)| 00:00:01 |
|   1 |  NESTED LOOPS                 |      |       |       |            |          |
|   2 |   NESTED LOOPS                |      |    17 |   476 |     2   (0)| 00:00:01 |
|   3 |    TABLE ACCESS BY INDEX ROWID| T1   |     2 |    28 |     1   (0)| 00:00:01 |
|*  4 |     INDEX RANGE SCAN          | T1N2 |    10 |       |     1   (0)| 00:00:01 |
|*  5 |    INDEX RANGE SCAN           | T2N4 |    11 |       |     1   (0)| 00:00:01 |
|   6 |   TABLE ACCESS BY INDEX ROWID | T2   |    11 |   154 |     1   (0)| 00:00:01 |
--------------------------------------------------------------------------------------

-- 비추, 하지만 LEADING 보다 강함

|