oracle 计划中的view,执行计划里的view
該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
FYI
Views
=====
When a view cannot be merged into the main query you will often see a
projection view operation. This indicates that the 'view' will be selected
from directly as opposed to being broken down into joins on the base tables.
A number of constructs make a view non mergeable. Inline views are also
non mergeable.
In the following example the select contains an inline view which cannot be
merged:
SQL> explain plan for
select ename,tot
from emp,
(select empno,sum(empno) tot from big_emp group by empno) tmp
where emp.empno = tmp.empno;
Query Plan
------------------------
SELECT STATEMENT [CHOOSE]
HASH JOIN
TABLE ACCESS FULL EMP [ANALYZED]
VIEW
SORT GROUP BY
INDEX FULL SCAN BE_IX
In this case the inline view tmp which contains an aggregate function cannot be
merged into the main query. The explain plan shows this as a view step.
Sometimes genreated VIEWs can be seen in the execution plan:
VIEW in the FROM clause (INLINE VIEW)
-------------------------------------
If a view cannot be merged into the main query then a VIEW keyword will
be shown in the plan to represent this.
explain plan for
select ename,tot
from emp,
(select empno x, sum(empno) tot from big_emp group by empno)
where emp.empno = x;
%ORACLE_HOME%/rdbms/admin/utlxpls.sql[This section is not visible to customers.]
7/17/13 Document 46234.1
https://mosemp.us.oracle.com/epmos/faces/ui/km/DocumentDisplay.jspx?_afrLoop=1561903930711194&id=46234.1&_afrWindowMode=0&_adf.ctrl-state=… 11/17
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 16 | 720 | | 46 |
|* 1 | HASH JOIN | | 16 | 720 | | 46 |
| 2 | TABLE ACCESS FULL | EMP | 16 | 304 | | 1 |
| 3 | VIEW | | 10000 | 253K| | 44 |
| 4 | SORT GROUP BY | | 10000 | 30000 | 248K| 44 |
| 5 | TABLE ACCESS FULL| BIG_EMP | 10000 | 30000 | | 24 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("EMP"."EMPNO"="from$_subquery$_002"."X")
"from$_subquery$_002" is the generated name of the inline view that is
produced in id=3 line. If the inline view was aliased in the from clause then
the system generated name ("from$_subquery$_002") would be replaced by this
alias.
Subquery isunnested but resultant view is not merged:
-----------------------------------------------------
In preoptimization there is a stage where subqueries can be unnested (combined
with base query). There are numerous and complex ruled governing this activity
which are beyond the scope of this article. However, if successful, a subquery
may be unnested to produce an inline view which represents the subquery. This
view is subject to view merging. If the view is non-mergeable then a VIEW keyword
will appear in the plan.
explain plan for
select ename
from emp
where emp.empno in (select empno x from big_emp group by empno);
%ORACLE_HOME%/rdbms/admin/utlxpls.sql[This section is not visible to customers.]
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 16 | 512 | | 46 |
|* 1 | HASH JOIN SEMI | | 16 | 512 | | 46 |
| 2 | TABLE ACCESS FULL | EMP | 16 | 304 | | 1 |
| 3 | VIEW | VW_NSO_1 | 10000 | 126K| | 44 |
| 4 | SORT GROUP BY | | 10000 | 30000 | 248K| 44 |
| 5 | TABLE ACCESS FULL| BIG_EMP | 10000 | 30000 | | 24 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("EMP"."EMPNO"="VW_NSO_1"."X")
In this example, the subquery is unnested but the resultant inline view
cannot be merged due to the 'group by'. This unmergeable view is given the
system generated name of "VW_NSO_1".
Note: In later versions, as with any code, certain inline views may be mergeable following
code improvements or as new features are introduced.
總結
以上是生活随笔為你收集整理的oracle 计划中的view,执行计划里的view的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle 效率问题,Oracle【诡
- 下一篇: 铁锅开锅小技巧?