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)