暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 自动跟踪仅

ASKTOM 2020-02-11
517

问题描述

嗨,
请你帮忙理解一下:
仅启用跟踪时,如何获得具有所有详细信息 (例如行E行等) 的执行计划。
我总是得到基本的计划细节,如行字节和仅cpu %。

如果您可以共享任何链接/您的博客以实现上述目标,那将很有帮助。

专家解答

SQL * Plus中的autotrace计划实际上是一个解释计划。所以可能会显示不正确的计划。并排除A/E行列等。

你可以用DBMS_XPlan得到这些。要做到这一点:

-设置服务器输出关闭
-使用/* gather_plan_statistics */ hint运行或将statistics_level设置为ALL
-运行您的查询
-调用DBMS_XPlan.display_cursor

例如。

set serveroutput off

select /*+ gather_plan_statistics */* from hr.employees;

select * 
from   table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT                                                                           
SQL_ID  cjmkg0hs1am4y, child number 0                                                        
-------------------------------------                                                        
select /*+ gather_plan_statistics */* from hr.employees                                      
                                                                                             
Plan hash value: 1445457117                                                                  
                                                                                             
-----------------------------------------------------------------------------------------    
| Id  | Operation         | Name      | Starts | E-Rows | A-Rows |   A-Time   | Buffers |    
-----------------------------------------------------------------------------------------    
|   0 | SELECT STATEMENT  |           |      1 |        |    107 |00:00:00.01 |       7 |    
|   1 |  TABLE ACCESS FULL| EMPLOYEES |      1 |    107 |    107 |00:00:00.01 |       7 |    
-----------------------------------------------------------------------------------------    


在以下位置阅读有关此的更多信息 (以及获得计划的其他方法):https://blogs.oracle.com/sql/how-to-create-an-execution-plan
文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论