oracle 10g 执行计划(explain plan)更为简单

Oracle 10g 查询计划(explain plan)更为简单

一:举个最简单例子:

执行SQL语句

explain plan for select count(*) from fx_users;

查询执行计划

select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1895104989
---------------------------------------------------------------------
| Id |              Operation        | Name     | Rows | Cost (%CPU)    | Time      |
---------------------------------------------------------------------
|   0 | SELECT STATEMENT |                |     1    |     1   (0)           | 00:00:01 |
|   1 | SORT AGGREGATE   |                |     1      |                          |                |
|   2 |   INDEX FULL SCAN| UN_USERS |    13   |                  1   (0)| 00:00:01 |
---------------------------------------------------------------------

就这么简单啊!

二 绑定变量执行计划

执行SQL语句

explain plan for select count(*) from fx_users where username= :p;

查询执行计划

select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 2217371508
------------------------------------------------------------------------------
| Id | Operation         | Name     | Rows | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------
|   0 | SELECT STATEMENT |          |     1 |    99 |     3   (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| FX_USERS |     1 |    99 |     3   (0)| 00:00:01 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter(TO_NUMBER("USERNAME")=1)

posted on 2010-07-02 08:05  松原蔡晓冬  阅读(595)  评论(0编辑  收藏  举报

导航