微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Oracle 执行计划说明

通过执行计划优化sql语句,查看执行计划3种方式

1)autotrace 指令 备注:该指令仅能在sqlplus窗口执行操作,plsqldevelope程序下无法执行该指令 (本人已验证该操作)

命令说明:

set autotrace off 认值关闭 autotrace

set autotrace on explain 仅显示执行计划

set autotrace on statistice 显示执行计划统计信息

set autotrace on 该选项包含 explain statistice


sql>set autotrace on

sql>select * from epm;

执行计划:

Execution Plan
----------------------------------------------------------
Plan hash value: 3956160932

--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%cpu)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 532 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| EMP | 14 | 532 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------


Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
7 consistent gets
0 physical reads
0 redo size
1630 bytes sent via sql*Net to client
523 bytes received via sql*Net from client
2 sql*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
14 rows processed


2)explain plan命令 该指令在plsqldevelope 已经验证


sql> explain plan for select * from employees;

Explained

sql> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1445457117
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%cpu)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 107 | 7383 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| EMPLOYEES | 107 | 7383 | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------

8 rows selected


3)使用Toad,PL/sql Developer工具


工具没验证


以上文档参考文献:http://blog.chinaunix.net/uid-21187846-id-3022916.html

原文地址:https://www.jb51.cc/oracle/210445.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐