当前位置: 首页 > 编程日记 > 正文

[20171225]查看并行执行计划注意的问题.txt

[20171225]查看并行执行计划注意的问题.txt

--//如果使用dbms_xplan.display_cursor查看并行执行计划注意一些问题,通过例子说明:

1.环境:

SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.测试:
SCOTT@book> create table t1 as select * from dba_objects ;
Table created.

SCOTT@book> alter session set statistics_level=all;
Session altered.

--//分析表略.

SCOTT@book> select /*+ parallel(t1,4) */ count(*) from t1;
  COUNT(*)
----------
     87016

SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  6yhkc72j9mnnt, child number 0
-------------------------------------
select /*+ parallel(t1,4) */ count(*) from t1
Plan hash value: 3110199320
-----------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation              | Name     | Starts | E-Rows | Cost (%CPU)| E-Time   |    TQ  |IN-OUT| PQ Distrib | A-Rows |   A-Time   | Buffers | Reads  |
-----------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |          |      1 |        |    96 (100)|          |        |      |            |      1 |00:00:00.02 |       5 |      1 |
|   1 |  SORT AGGREGATE        |          |      1 |      1 |            |          |        |      |            |      1 |00:00:00.02 |       5 |      1 |
|   2 |   PX COORDINATOR       |          |      1 |        |            |          |        |      |            |      4 |00:00:00.02 |       5 |      1 |
|   3 |    PX SEND QC (RANDOM) | :TQ10000 |      0 |      1 |            |          |  Q1,00 | P->S | QC (RAND)  |      0 |00:00:00.01 |       0 |      0 |
|   4 |     SORT AGGREGATE     |          |      0 |      1 |            |          |  Q1,00 | PCWP |            |      0 |00:00:00.01 |       0 |      0 |
|   5 |      PX BLOCK ITERATOR |          |      0 |  87016 |    96   (0)| 00:00:02 |  Q1,00 | PCWC |            |      0 |00:00:00.01 |       0 |      0 |
|*  6 |       TABLE ACCESS FULL| T1       |      0 |  87016 |    96   (0)| 00:00:02 |  Q1,00 | PCWP |            |      0 |00:00:00.01 |       0 |      0 |
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$1
   6 - SEL$1 / T1@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
   6 - access(:Z>=:Z AND :Z<=:Z)

--//全表扫描,但是注意看A-Rows实际上根本不对.看到是0行.而E-Rows看到是正确的.

SCOTT@book> select * from table(dbms_xplan.display_cursor('6yhkc72j9mnnt',NULL,'ALLSTATS LAST PEEKED_BINDS cost partition -projection -outline parallel'));
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  6yhkc72j9mnnt, child number 0
-------------------------------------
select /*+ parallel(t1,4) */ count(*) from t1
Plan hash value: 3110199320
---------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation              | Name     | Starts | E-Rows | Cost (%CPU)|    TQ  |IN-OUT| PQ Distrib | A-Rows |   A-Time   | Buffers |
---------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |          |      1 |        |    96 (100)|        |      |            |      1 |00:00:00.11 |       5 |
|   1 |  SORT AGGREGATE        |          |      1 |      1 |            |        |      |            |      1 |00:00:00.11 |       5 |
|   2 |   PX COORDINATOR       |          |      1 |        |            |        |      |            |      4 |00:00:00.11 |       5 |
|   3 |    PX SEND QC (RANDOM) | :TQ10000 |      0 |      1 |            |  Q1,00 | P->S | QC (RAND)  |      0 |00:00:00.01 |       0 |
|   4 |     SORT AGGREGATE     |          |      0 |      1 |            |  Q1,00 | PCWP |            |      0 |00:00:00.01 |       0 |
|   5 |      PX BLOCK ITERATOR |          |      0 |  87016 |    96   (0)|  Q1,00 | PCWC |            |      0 |00:00:00.01 |       0 |
|*  6 |       TABLE ACCESS FULL| T1       |      0 |  87016 |    96   (0)|  Q1,00 | PCWP |            |      0 |00:00:00.01 |       0 |
---------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   6 - access(:Z>=:Z AND :Z<=:Z)
--//加入parallel提示也是一样.
--//链接:raajeshwaran.blogspot.com/2017/12/gatherplanstatistics-hint-for-parallel.html
In a parallel execution the last process to execute the cursor is the Query coordinator (QC), typically this QC will
execute a small number of operations in the execution plan, while the majority of the operations in the plan was done by
the parallel execution server process. So when we issue the DBMS_XPLAN.DISPLAY_CURSOR and ask for the last execution we
only get the information about the operations in the plan that the QC actually executed. In this case the only operation
that QC did was return the final result to our SQL*Plus session, which is why the line 0 and 1 and 2 have entries in the
A-rows column.

In order to see A-rows values for all the operations in the plan, we have to use the FORMAT value as ALLSTATS ALL, which
will show you the execution statistics for ALL executions of the cursor.

SCOTT@book> select * from table(dbms_xplan.display_cursor('6yhkc72j9mnnt',NULL,'ALLSTATS ALL PEEKED_BINDS cost partition -projection -outline parallel'));
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  6yhkc72j9mnnt, child number 0
-------------------------------------
select /*+ parallel(t1,4) */ count(*) from t1
Plan hash value: 3110199320
-----------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation              | Name     | Starts | E-Rows | Cost (%CPU)| E-Time   |    TQ  |IN-OUT| PQ Distrib | A-Rows |   A-Time   | Buffers | Reads  |
-----------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |          |      2 |        |    96 (100)|          |        |      |            |      2 |00:00:00.13 |      10 |      1 |
|   1 |  SORT AGGREGATE        |          |      2 |      1 |            |          |        |      |            |      2 |00:00:00.13 |      10 |      1 |
|   2 |   PX COORDINATOR       |          |      2 |        |            |          |        |      |            |      8 |00:00:00.13 |      10 |      1 |
|   3 |    PX SEND QC (RANDOM) | :TQ10000 |      0 |      1 |            |          |  Q1,00 | P->S | QC (RAND)  |      0 |00:00:00.01 |       0 |      0 |
|   4 |     SORT AGGREGATE     |          |      7 |      1 |            |          |  Q1,00 | PCWP |            |      7 |00:00:00.10 |    2265 |   2179 |
|   5 |      PX BLOCK ITERATOR |          |      8 |  87016 |    96   (0)| 00:00:02 |  Q1,00 | PCWC |            |    152K|00:00:00.09 |    2590 |   2486 |
|*  6 |       TABLE ACCESS FULL| T1       |    104 |  87016 |    96   (0)| 00:00:02 |  Q1,00 | PCWP |            |    174K|00:00:00.04 |    2590 |   2486 |
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$1
   6 - SEL$1 / T1@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
   6 - access(:Z>=:Z AND :Z<=:Z)

--//而这里看到的A-Rows实际上多次执行后的累积,并不能反应真实的情况.使用参数all的情况导致的结果.

--//加入提示,生成新的执行计划:
SCOTT@book> select /*+ parallel(t1,4) test */ count(*) from t1;
  COUNT(*)
----------
     87016

SCOTT@book> select * from table(dbms_xplan.display_cursor(NULL,NULL,'ALLSTATS ALL PEEKED_BINDS cost partition -projection -outline parallel'));
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  6a3vj021614ft, child number 0
-------------------------------------
select /*+ parallel(t1,4) test */ count(*) from t1
Plan hash value: 3110199320
-----------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation              | Name     | Starts | E-Rows | Cost (%CPU)| E-Time   |    TQ  |IN-OUT| PQ Distrib | A-Rows |   A-Time   | Buffers | Reads  |
-----------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |          |      1 |        |    96 (100)|          |        |      |            |      1 |00:00:00.11 |       5 |      0 |
|   1 |  SORT AGGREGATE        |          |      1 |      1 |            |          |        |      |            |      1 |00:00:00.11 |       5 |      0 |
|   2 |   PX COORDINATOR       |          |      1 |        |            |          |        |      |            |      4 |00:00:00.11 |       5 |      0 |
|   3 |    PX SEND QC (RANDOM) | :TQ10000 |      0 |      1 |            |          |  Q1,00 | P->S | QC (RAND)  |      0 |00:00:00.01 |       0 |      0 |
|   4 |     SORT AGGREGATE     |          |      4 |      1 |            |          |  Q1,00 | PCWP |            |      4 |00:00:00.06 |    1295 |   1243 |
|   5 |      PX BLOCK ITERATOR |          |      4 |  87016 |    96   (0)| 00:00:02 |  Q1,00 | PCWC |            |  87016 |00:00:00.05 |    1295 |   1243 |
|*  6 |       TABLE ACCESS FULL| T1       |     52 |  87016 |    96   (0)| 00:00:02 |  Q1,00 | PCWP |            |  87016 |00:00:00.02 |    1295 |   1243 |
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$1
   6 - SEL$1 / T1@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
   6 - access(:Z>=:Z AND :Z<=:Z)

--//这样看到的执行计划才是比较真实的数值.

--//我的dpc.sql脚本如下:
select * from table(dbms_xplan.display_cursor(NVL('&1',NULL),NULL,'ALL ALLSTATS LAST PEEKED_BINDS cost partition -projection -outline &2'));
--//我写的脚本也存在问题,不过最后的last掩盖前面all参数的设置.^_^.

3.总结:
--//在设置statistics_level=all;或者提示gather_plan_statistics时,看到的并行执行计划要特别注意.

转载于:https://www.cnblogs.com/lfree/p/8116717.html

相关文章:

expires与etag控制页面缓存的优先级

expires指令控制HTTP应答中的“Expires”和“Cache-Control”Header头部信息&#xff0c;启动控制页面缓存的作用time:可以使用正数或负数。“Expires”头标的值将通过当前系统时间加上设定time值来设定。time值还控制"Cache-Control"的值&#xff1a;负数表示no-cac…

API 大赛决赛名单出炉,速来围观!

创新云转型&#xff0c;智慧云服务2021年移动云API应用创新开发大赛正在火热进行中各个赛道激烈PK优秀开发者同台切磋彰显实力&#xff01;10月14日&#xff0c;2021年移动云API应用创新开发大赛复赛在中移软件园双创路演大厅圆满举办。本次复赛分为移动赛道和企业赛道分别进行…

将日期yyyy-MM-dd转为数字大写的形式

/*** 将日期转大写* 例如&#xff1a;2013-05-13转为 二0一三年五月十三日* param date* return */public static String getDxDate(String date){String dateArr[] date.split("-");String year dateArr[0];String month dateArr[1];String day dateArr[2];Str…

DevExpress v17.2新版亮点—WPF篇(四)

2019独角兽企业重金招聘Python工程师标准>>> DevExpress年终击穿底价&#xff0c;单套授权低至67折&#xff01;仅剩最后6天&#xff01;查看详情>>> 用户界面套包DevExpress v17.2终于正式发布&#xff0c;本站将以连载的形式为大家介绍各版本新增内容。本…

CI框架验证码CAPTCHA 辅助函数的使用

使用CAPTCHA 辅助函数很方便生成验证码&#xff0c;但是图片是存储在文件夹下&#xff0c;不是输出流&#xff0c;感觉不够完美&#xff0c;可以拿来用用。 说明&#xff1a;产生4位的随机数&#xff0c;CI根目录下建立captcha文件夹。 <?php $this->load->helper(ca…

GitLab 上市,市值高达 149 亿美元!GitHub 的头号劲敌来了

整理 | 祝涛 出品 | CSDN当地时间周四&#xff0c;知名代码和资源托管服务平台 GitLab&#xff08;股票代码GTLB&#xff09;完成了IPO&#xff08;首次公开募股&#xff09;&#xff0c;在纳斯达克成功上市。GitLab在本次 IPO 中筹集了约 6.5 亿美元。GitLab此前曾计划I…

将ubuntu系统设置静态ip及ssh

2019独角兽企业重金招聘Python工程师标准>>> sudo vim /etc/network/interfaces 输入以下&#xff1a;auto lo iface lo inet loopback auto eno1 iface eno1 inet static address 192.168.1.197 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameserver 192.168…

ECMAScript 5 —— 单体内置对象之Math对象

ECMAScript 还为保存数学公式和信息提供了一个公共位置&#xff0c;即 Math 对象。与我们在 JavaScript 直接编写的计算功能相比&#xff0c;Math 对象提供的计算功能执行起来要快得多。Math 对象中还提供了辅助完成这些计算的属性和方法。 一. Math 对象的属性 Math 对象包含的…

织梦内容管理系统修改

1.如何去掉互动中心 修改根目录下templates——default——index.htm文件&#xff0c;删除以下内容 <div id"rightAD1" style:margin:10px auto"></div> <div class"usercenter">.....到</div> <!-- /usercenter --&…

斯坦福大学 AI100 报告发布:AI 发展速度惊人,但风险也正走进现实

‍‍作者 | 阳光来源 | 学术头条语言处理、计算机视觉和模式识别的巨大进步&#xff0c;意味着人工智能&#xff08;Artificial Intelligence&#xff0c;AI&#xff09;每天都在与人们的生活进行交互&#xff0c;从帮助人们选择电影&#xff0c;到帮助人们解决医疗诊断难题方面…

linux===Ubuntu 上安装 Node.js

https://www.cnblogs.com/andfly/p/6681487.html转载于:https://www.cnblogs.com/botoo/p/8118903.html

非计算机专业的学生,从事编程工作的上升壁垒是什么?

很多同学自己的专业并不是计算机&#xff0c;但是看到如今IT行业发展的这么好&#xff0c;也想转行学习编码。但是自己非科班出身&#xff0c;又到了快毕业的年纪&#xff0c;开始学习编程来得及吗&#xff1f;这些年来&#xff0c;很多培训机构都借鉴了少儿编程培训的经验&…

HTTP头信息中的参数Etag

服务器如果是集群&#xff0c;不同服务器返回的 Http Header 中的 Etag 参数不一样。如果是图片是程序生成的&#xff0c;我们可以用 no-cache 这些 header 来控制&#xff0c;但如果这些图片是 apache 或 nginx 等呢&#xff1f;下面开始介绍 Etag&#xff1a;Etag在HTTP1.1中…

利用JS使用POST方式提交请求的方法

2019独角兽企业重金招聘Python工程师标准>>> function post(url, params) {var temp document.createElement("form");temp.action url;temp.method "post";temp.style.display "none";for (var x in params) {var opt document…

input框取消光标颜色手机端不生效

<style> input{ color:transparent; } </style> <input value"我要隐藏光标">//文字颜色可以使用text-shadow属性<style> input{ color:transparent; text-shadow:0 0 0 red; } </style> PC端没问题&#xff0c;但是手机端测试无效。…

http响应Last-Modified和ETag以及Apache和Nginx中的配置

基础知识   1) 什么是”Last-Modified”?   在浏览器第一次请求某一个URL时&#xff0c;服务器端的返回状态会是200&#xff0c;内容是你请求的资源&#xff0c;同时有一个Last-Modified的属性标记此文件在服务期端最后被修改的时间&#xff0c;格式类似这样&#xff1a; …

全面分析再动手的习惯:链表的反转问题(递归和非递归方式)

定义一个方法&#xff08;函数&#xff09;&#xff0c;实现输入一个链表的头结点&#xff0c;然后可以反转这个链表的方向&#xff0c;并输出反转之后的链表的头结点。 typedef struct Node{int data;Node *next; } Node, *List; 链表类的问题&#xff0c;涉及到了很多指针的操…

Facebook 正在研究新型 AI 系统,以自我视角与世界进行交互

编译 | 禾木木出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;你是否能想象 AI 以第一人称视角来理解世界是什么样的呢&#xff1f;未来&#xff0c;以第一人称视角理解世界的 AI 可以开启沉浸式体验的新时代。增强现实&#xff08;AR&#xff09;眼镜和虚拟现实&…

docker-2-简单使用docker-ce

安装请看docker-ce安装文档 docker命令合集 参考docker --help 选项 -D 使用debug模式-l 日志级别(有debug|info|warn|error|fatal)&#xff0c;默认info-v 显示版本管理命令config 管理docker配置container 管理容器image 管理镜像network 管理网络service swarm 常用命令atta…

Apache启用mod_expires模块

mod_expires可以减少10%左右的重复请求&#xff0c;让重复的用户对指定的页面请求结果都CACHE在本地&#xff0c;根本不向服务器发出请求。 在使用之前,首先要确认一下”mod_expires”模组是否有启用.如果是自己安装Apache来架设网页主机的话,这里我们可以透过编辑Apache的”ht…

用 Pyecharts 制作炫酷的可视化大屏

作者 | 俊欣来源 | 关于数据分析与可视化前两篇Pyecharts的文章来帮我们简单的梳理了一下可以用Pyecharts来绘制哪些图表之后&#xff0c;本篇文章我们用pyecharts里面的一些组件&#xff0c;将绘制的图表都组合起来首先Grid组件首先介绍Pyecharts模块当中的Grid组件&#xff0…

compass安装使用960 Grid System

960 Grid System 是一个CSS的页面布局框架 demo: http://960.gs/demo.html 前提&#xff1a;安装Ruby 、NodeJS 步骤1&#xff1a;在命令行下安装css插件&#xff1a; gem install compass-960-plugin 步骤2&#xff1a;创建my_project项目&#xff1a; compass create -r nin…

C语言竟成TIOBE年度编程语言候选!苹果iPhone 7卖得最好!

每年这个时候&#xff0c;都是TIOBE榜单评选年度编程语言的时候。今年&#xff0c;Kotlin成为竞争的热门&#xff0c;让人意外的是&#xff0c;C语言居然也成为了候选编程语言之一。自从被Java摘走王者桂冠&#xff0c;C语言几乎是处于持续下滑状态&#xff0c;没想到2017年竟然…

奇怪吸引子---QiChen

奇怪吸引子是混沌学的重要组成理论&#xff0c;用于演化过程的终极状态&#xff0c;具有如下特征&#xff1a;终极性、稳定性、吸引性。吸引子是一个数学概念&#xff0c;描写运动的收敛类型。它是指这样的一个集合&#xff0c;当时间趋于无穷大时&#xff0c;在任何一个有界集…

简介+原理+绘制,详解 Python「瀑布图」的整个制作流程!

作者|黄伟呢来源|数据分析与统计学之美简介瀑布图&#xff0c;由麦肯锡顾问公司所独创的图表类型&#xff0c;因为形似瀑布流水&#xff0c;所以被大家称之为瀑布图(Waterfall Plot)&#xff0c;在企业经营分析、财务分析中使用较多&#xff0c;用以表示企业成本的构成、变化等…

Ubuntu 忘记root登录密码的解决办法

2019独角兽企业重金招聘Python工程师标准>>> 之前做了个虚拟机&#xff0c;最近需要用到&#xff0c;密码忘记了&#xff0c;下面是在忘记密码的情况下登录系统休修改密码&#xff0c;需要进入GRUB修改kernel镜像启动参数 1、重启电脑长按shift键直到进入下图进入GR…

10月21日!API 大赛决赛暨移动云开发者论坛邀您见证数字创新的力量

2021年7月&#xff0c;移动云API应用创新开发大赛正式启动&#xff0c;历时近两个月的时间&#xff0c;共计报名889人&#xff0c;最终提交作品166项。经过前期初审、初赛、复赛等环节&#xff0c;最终企业、移动和高校赛道共29个目团队成功问鼎移动云API应用创新开发大赛决赛榜…

负载均衡环境中和如何设置Expires和Etag

在负载均衡环境中&#xff08;LVS, LoadBalance&#xff09;为了减少浏览器数据的重复请求操作&#xff0c;一般需要设置 Http Header 的 Etage 和 Expires 告诉浏览器请求数据是否已过期。以下内容主要考虑Apachesquid 环境 ETag Header是文件修改时间、文件大小和inode号生成…

C++之typedef 小记

2019独角兽企业重金招聘Python工程师标准>>> &#xfeff;&#xfeff; 以前曾不知道为何要用typedef&#xff0c;随着开发的深入&#xff0c;真正感受到了其内涵所在&#xff1a; 1.如&#xff1a;typedef int DataType 接下来项目中的几万行代码中&#xff0c;如果…

Android Go初探

Android Ore(Go edition) 简介&#xff1a; Android Go并不是一个独立的操作系统&#xff0c;它只是Android O的一种轻量级配置方案&#xff0c;专为1GB以下内存的机型设计&#xff0c; 在这种设置下&#xff0c;一些消耗大量资源的功能将被关闭&#xff0c;同时预装的应用也是…