oracle hint no_merge
oracle hint no_merge強制oracle不把子查詢inline view和outer view外層查詢合併為一個單一的查詢,即子查詢執行出結果集再和外層查詢的其它結果集進行關聯操作
下為測試結果
SQL> explain plan for select /*+ no_merge(d) */ e.empno,e.ename,d.dname from em
p e,(select deptno,dname from dept where deptno=20) d where e.deptno=d.deptno;
已解釋。
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------
Plan hash value: 1228445785
--------------------------------------------------------------------------------
---------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
ime |
--------------------------------------------------------------------------------
---------
| 0 | SELECT STATEMENT | | 4 | 140 | 4 (25)| 0
0:00:01 |
|* 1 | HASH JOIN | | 4 | 140 | 4 (25)| 0
0:00:01 |
| 2 | VIEW | | 1 | 22 | 1 (0)| 0
0:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 13 | 1 (0)| 0
0:00:01 |
|* 4 | INDEX UNIQUE SCAN | PK_DEPT | 1 | | 0 (0)| 0
0:00:01 |
| 5 | TABLE ACCESS FULL | EMP | 12 | 156 | 2 (0)| 0
0:00:01 |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------
--------------------------------------------------------------------------------
---------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("E"."DEPTNO"="D"."DEPTNO")
4 - access("DEPTNO"=20)
已選擇18行。
p e,(select deptno,dname from dept where deptno=20) d where e.deptno=d.deptno;
已解釋。
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------
Plan hash value: 1228445785
--------------------------------------------------------------------------------
---------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
ime |
--------------------------------------------------------------------------------
---------
| 0 | SELECT STATEMENT | | 4 | 140 | 4 (25)| 0
0:00:01 |
|* 1 | HASH JOIN | | 4 | 140 | 4 (25)| 0
0:00:01 |
| 2 | VIEW | | 1 | 22 | 1 (0)| 0
0:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 13 | 1 (0)| 0
0:00:01 |
|* 4 | INDEX UNIQUE SCAN | PK_DEPT | 1 | | 0 (0)| 0
0:00:01 |
| 5 | TABLE ACCESS FULL | EMP | 12 | 156 | 2 (0)| 0
0:00:01 |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------
--------------------------------------------------------------------------------
---------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("E"."DEPTNO"="D"."DEPTNO")
4 - access("DEPTNO"=20)
已選擇18行。
SQL> explain plan for select e.empno,e.ename,d.dname from emp e,(select deptno,d
name from dept where deptno=20) d where e.deptno=d.deptno;
已解釋。
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------
Plan hash value: 568005898
--------------------------------------------------------------------------------
--------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Ti
me |
--------------------------------------------------------------------------------
--------
| 0 | SELECT STATEMENT | | 3 | 78 | 3 (0)| 00
:00:01 |
| 1 | NESTED LOOPS | | 3 | 78 | 3 (0)| 00
:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 13 | 1 (0)| 00
:00:01 |
|* 3 | INDEX UNIQUE SCAN | PK_DEPT | 1 | | 0 (0)| 00
:00:01 |
|* 4 | TABLE ACCESS FULL | EMP | 3 | 39 | 2 (0)| 00
:00:01 |
--------------------------------------------------------------------------------
--------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("DEPTNO"=20)
4 - filter("E"."DEPTNO"=20)
已選擇17行。
name from dept where deptno=20) d where e.deptno=d.deptno;
已解釋。
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------
Plan hash value: 568005898
--------------------------------------------------------------------------------
--------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Ti
me |
--------------------------------------------------------------------------------
--------
| 0 | SELECT STATEMENT | | 3 | 78 | 3 (0)| 00
:00:01 |
| 1 | NESTED LOOPS | | 3 | 78 | 3 (0)| 00
:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 13 | 1 (0)| 00
:00:01 |
|* 3 | INDEX UNIQUE SCAN | PK_DEPT | 1 | | 0 (0)| 00
:00:01 |
|* 4 | TABLE ACCESS FULL | EMP | 3 | 39 | 2 (0)| 00
:00:01 |
--------------------------------------------------------------------------------
--------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("DEPTNO"=20)
4 - filter("E"."DEPTNO"=20)
已選擇17行。
小記:no_merge適用於子查詢結果集很小,試想如果讓oracle merge,可能子成本就很高多了.因為沒有filter無效的記錄,導致成本提升
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-751296/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用no_merge結合其它hint完全控制Oracle執行計劃Oracle
- oracle hintOracle
- ORACLE 部分HINTOracle
- oracle hint (續)Oracle
- Oracle Hint 精華Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(五)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(四)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(三)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(二)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(一)Oracle
- oracle之hint概述Oracle
- oracle常見hintOracle
- oracle hint簡述Oracle
- oracle hint (續-0)Oracle
- oracle hint_no_indexOracleIndex
- Oracle Hint 精華文章Oracle
- 常用的Oracle HintOracle
- Oracle Hint 詳解Oracle
- Oracle Hint的用法Oracle
- oracle hint之hint_index_ffs,index_joinOracleIndex
- ORACLE的HINT詳解Oracle
- Oracle中Hint隨記Oracle
- oracle hint_no_expand_no_factOracle
- oracle hint_cache_nocacheOracle
- Oracle 常用HINT介紹Oracle
- (轉)Oracle Hint的用法Oracle
- oracle hint有效範圍Oracle
- ORACLE使用HINT的方法Oracle
- Oracle索引HINT的使用Oracle索引
- Oracle中的sql hintOracleSQL
- zt_Oracle hint driving_site Hint的用法Oracle
- Oracle中常見的Hint(一)Oracle
- Oracle之Hint使用總結Oracle
- oracle hint_leadingOracle
- oracle hint_noappend_parallelOracleAPPParallel
- oracle hint_no_parallel_no_parallel_indexOracleParallelIndex
- oracle hint_parallel_parallel_indexOracleParallelIndex
- 常見Oracle HINT的用法Oracle