第一种执行计划:
第二种执行计划:
第三种执行计划:
点击(此处)折叠或打开
- SQL> explain plan
- 2 set statement_id ='test1'
- 3 into plan_table
- 4 for select * from daiqi.t_baidu_doc
- 5 ;
-
- Explained.
-
- SQL> select lpad(' ',level-1)||operation||' '||options||' '||
- 2 object_name "PLan"
- 3 from plan_table
- 4 connect by prior id= parent_id
- 5 and prior statement_id = statement_id
- 6 start with id =0 and statement_id ='&1'
- 7 order by id;
- Enter value for 1: test1
- old 6: start with id =0 and statement_id ='&1'
- new 6: start with id =0 and statement_id ='test1'
-
- PLan
- --------------------------------------------------------------------------------
- SELECT STATEMENT
- TABLE ACCESS FULL T_BAIDU_DOC
第二种执行计划:
点击(此处)折叠或打开
- SQL> explain plan for
- 2 select * from daiqi.t_baidu_doc;
-
- Explained.
-
- SQL> set linesize 130;
- SQL> set pagesize 0;
- SQL> select * from table(DBMS_XPLAN.DISPLAY);
- Plan hash value: 149575921
-
- ---------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- ---------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 4848K| 795M| 31955 (1)| 00:06:24 |
- | 1 | TABLE ACCESS FULL| T_BAIDU_DOC | 4848K| 795M| 31955 (1)| 00:06:24 |
第三种执行计划:
点击(此处)折叠或打开
- SQL>@$ORACLE_HOME/rdbms/admin/utlxplan.sql
-
- Autotrace特性.
-
- SET AUTOTRACE ON EXPLAIN: 此选项仅生成执行计划,不执行查询本身.
- SET AUTOTRACE ON STATISTICS: 此选项仅显示SQL语句的执行统计数据.
- SET AUTOTRACE ON: 此选项既显示执行计划,又显示SQL语句的执行统计数据
-
- SQL> set autotrace on explain;
- SQL> select count(*) from daiqi.t_baidu_doc;
-
- COUNT(*)
- ----------
- 4848509
-
-
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 4162034560
-
- ------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Cost (%CPU)| Time |
- ------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 1 | 2858 (2)| 00:00:35 |
- | 1 | SORT AGGREGATE | | 1 | | |
- | 2 | INDEX FAST FULL SCAN| SYS_C0010938 | 4848K| 2858 (2)| 00:00:35 |
- ------------------------------------------------------------------------------
-
- SQL>