当前位置: 代码迷 >> Oracle管理 >> 执行计划吗?该如何处理
  详细解决方案

执行计划吗?该如何处理

热度:37   发布时间:2016-04-24 05:52:59.0
执行计划吗?
SQL> select count(*) from tb_clfb;

已用时间: 00: 00: 00.02

Statistics
----------------------
  0 recursive calls
  0 db block gets
  1112 consistent gets
  643 physical reads
  0 redo size
  375 bytes sent via SQL*Net to client
  503 bytes received via SQL*Net from client
  2 SQL*Net roundtrips to/from client
  0 sorts (memory)
  0 sorts (disk)
  1 rows processed

------解决方案--------------------
SQL code
SQL> select * from t where rownum=1;       IDX----------CNAME--------------------------------------------         1aExecution Plan----------------------   0      SELECT STATEMENT Optimizer=CHOOSE   1    0   COUNT (STOPKEY)   2    1     TABLE ACCESS (FULL) OF 'T'Statistics----------------------          0  recursive calls          0  db block gets          0  consistent gets          0  physical reads          0  redo size          0  bytes sent via SQL*Net to client          0  bytes received via SQL*Net from client          0  SQL*Net roundtrips to/from client          0  sorts (memory)          0  sorts (disk)          1  rows processed
------解决方案--------------------
要有
Execution Plan
----------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 COUNT (STOPKEY)
2 1 TABLE ACCESS (FULL) OF 'T'
才能看得出,
你是不是用的

set autotrace on statistics

这样看不到 Plan


直接set autotrace on看看信息

------解决方案--------------------
探讨
执行set autotrace on显示

SQL> set autotrace on;
SP2-0613: 无法验证 PLAN_TABLE 格式或实体
SP2-0611: 启用EXPLAIN报告时出错

------解决方案--------------------
SQL code
1: 打开PL\SQL Developer工具,按F52:SET AUTOTRACE TRACEONLY;   -- 安装执行计划 FYI: http://www.eygle.com/faq/AutoTrace.htm如果想强制使用索引:-- 查索引NAME:SQL> SELECT TABLE_NAME,  2         INDEX_NAME  3    FROM ALL_INDEXES  4   WHERE TABLE_OWNER = UPPER('SCOTT')  5     AND TABLE_NAME = UPPER('EMP');TABLE_NAME                     INDEX_NAME------------------------------ ------------------------------EMP                            PK_EMPSQL> SELECT /*+ INDEX(EMP PK_EMP)*/ EMPNO,ENAME  2    FROM EMP  3   WHERE EMPNO >= '7782';EMPNO ENAME----- ---------- 7782 CLARK 7788 SCOTT 7839 KING 7844 TURNER 7876 ADAMS 7900 JAMES 7902 FORD 7934 MILLER8 rows selected