subquery unnesting、Subquery unnesting and View Merge
本文內(nèi)容系轉(zhuǎn)載,如有侵犯你的知識(shí)產(chǎn)權(quán),煩請(qǐng)及時(shí)告知本人,本人將即刻停止侵權(quán)行為。
參考網(wǎng)址:http://space.itpub.net/27064837/viewspace-746501
http://space.itpub.net/471666/viewspace-694608
? ? ? ? ? ? ? ? ??http://jonathanlewis.wordpress.com/2008/02/17/pushing-predicates-2/
? ? ? ? ? ? ? ? ??http://www.oraclefans.cn/forum/showtopic.jsp?rootid=6963
?http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/queries008.htm
1、Unnesting of Nested Subqueries
Unnesting of Nested Subqueries
Subqueries are?nested?when they appear in the?WHERE?clause of the parent statement. When Oracle Database evaluates a statement with a nested subquery, it must evaluate the subquery portion multiple times and may overlook some efficient access paths or joins.
Subquery unnesting?unnests and merges the body of the subquery into the body of the statement that contains it, allowing the optimizer to consider them together when evaluating access paths and joins. The optimizer can unnest most subqueries, with some exceptions. Those exceptions include hierarchical subqueries and subqueries that contain a?ROWNUM?pseudocolumn, one of the set operators, a nested aggregate function, or a correlated reference to a query block that is not the immediate outer query block of the subquery.
Assuming no restrictions exist, the optimizer automatically unnests some (but not all) of the following nested subqueries:
-
Uncorrelated?IN?subqueries
-
IN?and?EXISTS?correlated subqueries, as long as they do not contain aggregate functions or a?GROUP?BY?clause
You can enable?extended subquery unnesting?by instructing the optimizer to unnest additional types of subqueries:
? ? ? 1、 You can unnest an uncorrelated?NOT?IN?subquery by specifying the?HASH_AJ?or?MERGE_AJ?hint in the subquery.
? ? ? 2、You can unnest other subqueries by specifying the?UNNEST?hint in the subquery
對(duì)嵌套子查詢進(jìn)行解嵌套:
? ? ?當(dāng)子查詢出現(xiàn)在主查詢的where條件的時(shí)候,它們是嵌套的,當(dāng)Oracle對(duì)子查詢進(jìn)行驗(yàn)證的時(shí)候,需要多次的驗(yàn)證子查詢,并且要為其選擇一個(gè)高效的訪問路徑和連接方式。
? ?Subquery unnesting?將子查詢解套并且合并在包含他的主查詢的語句中,并且允許優(yōu)化器選擇訪問路徑和連接方式的時(shí)候,將他們放在一塊考慮,優(yōu)化器可以將大部分的嵌套查詢進(jìn)行轉(zhuǎn)換,除了一些特殊的,這些特殊情況包括:
層次查詢、包含偽列rownum的子查詢、聚合函數(shù)、不是主查詢的直接子查詢語句。
? ?可以使用Hint來指導(dǎo)優(yōu)化器來優(yōu)化如下的子查詢:
? ? 1、對(duì)于not in可以在子查詢中使用HASH_AJ或MERGE_AJ的hint
? ? 2、在子查詢中直接使用UNNEST
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/caroline/archive/2012/11/25/2787694.html
總結(jié)
以上是生活随笔為你收集整理的subquery unnesting、Subquery unnesting and View Merge的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 7月清北学堂培训 Day 5
- 下一篇: 2.2.1 Sqoop1的基本架构