代码改变世界

SQL Tuning 基础概述02 - Explain plan的使用

2014-08-31 23:47 by AlfredZhao, ... 阅读, ... 评论, 收藏, 编辑

1.explain plan的使用

SQL> explain plan for delete from t_jingyu;

Explained.

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

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 1368587462

-----------------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Cost (%CPU)| Time     |
-----------------------------------------------------------------------
|   0 | DELETE STATEMENT   |          |  1864K|   978   (2)| 00:00:12 |
|   1 |  DELETE            | T_JINGYU |       |            |          |
|   2 |   TABLE ACCESS FULL| T_JINGYU |  1864K|   978   (2)| 00:00:12 |
-----------------------------------------------------------------------

Note
-----
   - dynamic sampling used for this statement (level=2)

13 rows selected

 2.explain plan 只是显示执行计划,并不会真正执行delete语句·

SQL> select count(*) from t_jingyu;

  COUNT(*)
----------
   2097152