oracle 解释计划和执行计划的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10572619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
difference between explain plan and execution plan
提问by Gaurav Soni
Can anyone explain me what is the difference between execution plan and explain plan.
谁能解释一下执行计划和解释计划之间的区别。
When I execute
当我执行
set autotrace traceonly;
select * from emp where empno=7369;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer Mode=ALL_ROWS (Cost=1 Card=1 Bytes=38)
1 0 TABLE ACCESS BY INDEX ROWID SCOTT.EMP (Cost=1 Card=1 Bytes=38)
2 1 INDEX UNIQUE SCAN SCOTT.PK_EMP (Cost=0 Card=1)
Explain Plan
explain plan for select * from emp where empno=7369;
select * from table(dbms_xplan.display);
Plan hash value: 2949544139
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 38 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 38 | 1 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 0 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
I am getting the same output, so what is the difference between the two.
我得到相同的输出,那么两者之间有什么区别。
采纳答案by a_horse_with_no_name
explain plan
is the statement that is used to display the execution plan.
explain plan
是用于显示执行计划的语句。
The two samples you have shown are just formatted differently, that's all.
您展示的两个示例只是格式不同,仅此而已。
You did not tell us how exactly you generated those outputs nor which tool you were using.
您没有告诉我们您是如何准确生成这些输出的,也没有告诉我们您使用的是哪种工具。
But if'm not mistaken, one of them is the output of an autotrace
inside SQL*Plus the other the output when using of of the procedures of the dbms_xplan
package.
但如果没记错的话,其中一个是autotrace
SQL*Plus 内部的输出,另一个是使用dbms_xplan
包的程序时的输出。
回答by steve godfrey
The explain plan is what the optimizer thinks will happen when you run, the execution plan is actually happened when you ran the query.
解释计划是优化器在您运行时认为会发生的事情,执行计划实际上是在您运行查询时发生的。
See link here.
请参阅此处的链接。
http://tkyte.blogspot.co.uk/2007/04/when-explanation-doesn-sound-quite.html
http://tkyte.blogspot.co.uk/2007/04/when-explanation-doesn-sound-quite.html