基于oracle的应用系统很多性能问题,是由应用系统sql性能低劣引起的,所以,sql的性能优化很重要,分析与优化sql的性能一般通过查看该sql的执行计划。
一、什么是执行计划
一条查询语句在oracle中的执行过程或访问路径的描述。
二、如何查看执行计划
1、set autotrace on;
2、explain plan for sql语句;
select plan_table_output from table(dbms_xplan.display());
3、通过第3方工具,如plsql developer(f5查看执行计划)、toad等
三、执行计划详细分析
SQL> explain plan for select * from scott.emp a,scott.emp b where a.empno=b.mgr and b.mgr is not null;
Explained
SQL> select plan_table_output from table(dbms_xplan.display());
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
-----------------------------