oracle hint_leading

wisdomone1發表於2012-12-20
oracle hint_leading_merge
1,leading
  1,比ordered功能更多
  2,如下明確看出leading可以發變首表
  3,如果指定了ordered,優先順序高於leading
 
SQL> explain plan for select emp.empno,dept.dname from emp,dept where emp.deptno
=dept.deptno;
已解釋。
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 615168685
---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |    12 |   240 |     5  (20)| 00:00:01 |
|*  1 |  HASH JOIN         |      |    12 |   240 |     5  (20)| 00:00:01 |
|   2 |   TABLE ACCESS FULL| DEPT |     8 |   104 |     2   (0)| 00:00:01 |
|   3 |   TABLE ACCESS FULL| EMP  |    12 |    84 |     2   (0)| 00:00:01 |
---------------------------------------------------------------------------

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("EMP"."DEPTNO"="DEPT"."DEPTNO")
已選擇15行。
SQL> explain plan for select /*+ leading(emp dept) */ emp.empno,dept.dname from
emp,dept where emp.deptno=dept.deptno;
已解釋。
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1123238657
---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |    12 |   240 |     5  (20)| 00:00:01 |
|*  1 |  HASH JOIN         |      |    12 |   240 |     5  (20)| 00:00:01 |
|   2 |   TABLE ACCESS FULL| EMP  |    12 |    84 |     2   (0)| 00:00:01 |
|   3 |   TABLE ACCESS FULL| DEPT |     8 |   104 |     2   (0)| 00:00:01 |
---------------------------------------------------------------------------

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("EMP"."DEPTNO"="DEPT"."DEPTNO")
已選擇15行。
SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-751379/,如需轉載,請註明出處,否則將追究法律責任。

相關文章