重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2629|回复: 0
打印 上一主题 下一主题

[范例] 使用 gather_plan_statistics hint 产生执行计划

[复制链接]
跳转到指定楼层
楼主
发表于 2017-1-17 18:27:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
、首先sqlplus登陆当前用户
2、执行  运行 sql语句 ,在语句中加入     /*+ gather_plan_statistics */
例子: 执行  sql 语句  select   /*+ gather_plan_statistics */  count(employee_id) from hr.employees where department_id=50;
得到结果  :
COUNT(1)
----------
45
3、执行   查看计划    select * from table(dbms_xplan.display_cursor(NULL,NULL,'ALLSTATS'));
得到结果:

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------

SQL_ID  4dxpaqxz24a4q, child number 0
-------------------------------------
select   /*+ gather_plan_statistics */  count(employee_id) from
hr.employees where department_id=50
Plan hash value: 2271004725
--------------------------------------------------------------------------------

| Id  | Operation         | Name              | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
--------------------------------------------------------------------------------

|   0 | SELECT STATEMENT  |                   |      1 |        |      1 |00:00:00.01 |       1 | PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------------------------------------------------------
|   1 |  SORT AGGREGATE   |                   |      1 |      1 |      1 |00:00:00.01 |       1 |
|*  2 |   INDEX RANGE SCAN| EMP_DEPARTMENT_IX |      1 |     45 |     45 |00:00:00.01 |       1 |
-------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - access("DEPARTMENT_ID"=50)

20 rows selected.
SQL>


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-19 22:47 , Processed in 0.100468 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表