解释计划和执行计划之间的差异 [英] difference between explain plan and execution plan
问题描述
谁能向我解释执行计划和解释计划之间的区别.
Can anyone explain me what is the difference between execution plan and explain plan.
执行时
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.
推荐答案
explain plan
是用于显示执行计划的语句.
explain plan
is the statement that is used to display the execution 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.
但是,如果没有记错的话,其中之一是SQL * Plus内部的autotrace
的输出,另一个是使用dbms_xplan
包的过程时的输出.
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.
这篇关于解释计划和执行计划之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!