subquery unnesting、Subquery unnesting and View Merge
本文內容系轉載,如有侵犯你的知識產權,煩請及時告知本人,本人將即刻停止侵權行為。
參考網址: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
對嵌套子查詢進行解嵌套:
? ? ?當子查詢出現在主查詢的where條件的時候,它們是嵌套的,當Oracle對子查詢進行驗證的時候,需要多次的驗證子查詢,并且要為其選擇一個高效的訪問路徑和連接方式。
? ?Subquery unnesting?將子查詢解套并且合并在包含他的主查詢的語句中,并且允許優化器選擇訪問路徑和連接方式的時候,將他們放在一塊考慮,優化器可以將大部分的嵌套查詢進行轉換,除了一些特殊的,這些特殊情況包括:
層次查詢、包含偽列rownum的子查詢、聚合函數、不是主查詢的直接子查詢語句。
? ?可以使用Hint來指導優化器來優化如下的子查詢:
? ? 1、對于not in可以在子查詢中使用HASH_AJ或MERGE_AJ的hint
? ? 2、在子查詢中直接使用UNNEST
?
?
轉載于:https://www.cnblogs.com/caroline/archive/2012/11/25/2787694.html
總結
以上是生活随笔為你收集整理的subquery unnesting、Subquery unnesting and View Merge的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 7月清北学堂培训 Day 5
- 下一篇: Centos7安装Nginx1.14.0