Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1984505
  • 博文数量: 176
  • 博客积分: 1857
  • 博客等级: 上尉
  • 技术积分: 2729
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-14 22:55
个人简介

吾生有涯,而知无涯,适当止学.循序渐进,步步提升 Talk is cheap, show me the code.

文章分类

全部博文(176)

文章存档

2019年(1)

2018年(14)

2017年(20)

2016年(31)

2015年(15)

2014年(5)

2013年(10)

2012年(80)

分类: Oracle

2013-04-17 16:33:17

第一种执行计划:


点击(此处)折叠或打开

  1. SQL> explain plan
  2.   2 set statement_id ='test1'
  3.   3 into plan_table
  4.   4 for select * from daiqi.t_baidu_doc
  5.   5 ;

  6. Explained.

  7. SQL> select lpad(' ',level-1)||operation||' '||options||' '||
  8.   2 object_name "PLan"
  9.   3 from plan_table
  10.   4 connect by prior id= parent_id
  11.   5 and prior statement_id = statement_id
  12.   6 start with id =0 and statement_id ='&1'
  13.   7 order by id;
  14. Enter value for 1: test1
  15. old 6: start with id =0 and statement_id ='&1'
  16. new 6: start with id =0 and statement_id ='test1'

  17. PLan
  18. --------------------------------------------------------------------------------
  19. SELECT STATEMENT
  20.  TABLE ACCESS FULL T_BAIDU_DOC



第二种执行计划:


点击(此处)折叠或打开

  1. SQL> explain plan for
  2.   2 select * from daiqi.t_baidu_doc;

  3. Explained.

  4. SQL> set linesize 130;
  5. SQL> set pagesize 0;
  6. SQL> select * from table(DBMS_XPLAN.DISPLAY);
  7. Plan hash value: 149575921

  8. ---------------------------------------------------------------------------------
  9. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
  10. ---------------------------------------------------------------------------------
  11. | 0 | SELECT STATEMENT | | 4848K| 795M| 31955 (1)| 00:06:24 |
  12. | 1 | TABLE ACCESS FULL| T_BAIDU_DOC | 4848K| 795M| 31955 (1)| 00:06:24 |


第三种执行计划:


点击(此处)折叠或打开

  1. SQL>@$ORACLE_HOME/rdbms/admin/utlxplan.sql

  2. Autotrace特性.

  3. SET AUTOTRACE ON EXPLAIN: 此选项仅生成执行计划,不执行查询本身.
  4. SET AUTOTRACE ON STATISTICS: 此选项仅显示SQL语句的执行统计数据.
  5. SET AUTOTRACE ON: 此选项既显示执行计划,又显示SQL语句的执行统计数据

  6. SQL> set autotrace on explain;
  7. SQL> select count(*) from daiqi.t_baidu_doc;

  8.   COUNT(*)
  9. ----------
  10.    4848509


  11. Execution Plan
  12. ----------------------------------------------------------
  13. Plan hash value: 4162034560

  14. ------------------------------------------------------------------------------
  15. | Id | Operation | Name | Rows | Cost (%CPU)| Time |
  16. ------------------------------------------------------------------------------
  17. | 0 | SELECT STATEMENT | | 1 | 2858 (2)| 00:00:35 |
  18. | 1 | SORT AGGREGATE | | 1 | | |
  19. | 2 | INDEX FAST FULL SCAN| SYS_C0010938 | 4848K| 2858 (2)| 00:00:35 |
  20. ------------------------------------------------------------------------------

  21. SQL>


阅读(2464) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~