如何测试Oracle并行执行的并行度状况
2017-09-21 12:55
387 查看
如何测试Oracle并行执行的并行度状况:
可以通过如下的脚本,来查看要求的并行度,和实际获得的并行度。
脚本来自:
http://askdba.org/weblog/forums/topic/query-to-identify-parallel-slaves/
col username for a12
col module for a10 trunc
col state for a20
col "QC SID" for A6
col SID for a10
col "QC/Slave" for A10
col "ReqDOP" for 999
col "ActDOP" for 999
col "slave set" for A10
col event for a25 trunc
col action for a20 trunc
col p1text for a20 trunc
col secwait for 99999
col state for a10 trunc
col object for a25 trunc
col command for a15 trunc
set pages 300 lines 300
select
s.inst_id,
decode(px.qcinst_id,NULL,s.username,
' - '||lower(substr(s.program,length(s.program)-4,4) ) ) "Username",
decode(px.qcinst_id,NULL, 'QC', '(Slave)') "QC/Slave" ,
to_char( px.server_set) "Slave Set",
to_char(s.sid) "SID",
decode(px.qcinst_id, NULL ,to_char(s.sid) ,px.qcsid) "QC SID",
px.req_degree "Requested DOP",
px.degree "Actual DOP",s.module,s.sql_id,s.event,s.status
from
gv$px_session px,
gv$session s
where
px.sid=s.sid (+) and
px.serial#=s.serial# and
px.inst_id = s.inst_id
order by 2 desc;
在Oracel 11.2.0.4进行实际测试,有效。
实际例子:
$cat q00.sql
col username for a12
col module for a10 trunc
col state for a20
col "QC SID" for A6
col SID for a10
col "QC/Slave" for A10
col "ReqDOP" for 999
col "ActDOP" for 999
col "slave set" for A10
col event for a25 trunc
col action for a20 trunc
col p1text for a20 trunc
col secwait for 99999
col state for a10 trunc
col object for a25 trunc
col command for a15 trunc
set pages 300 lines 300
select
s.inst_id,
decode(px.qcinst_id,NULL,s.username,
' - '||lower(substr(s.program,length(s.program)-4,4) ) ) "Username",
decode(px.qcinst_id,NULL, 'QC', '(Slave)') "QC/Slave" ,
to_char( px.server_set) "Slave Set",
to_char(s.sid) "SID",
decode(px.qcinst_id, NULL ,to_char(s.sid) ,px.qcsid) "QC SID",
px.req_degree "Requested DOP",
px.degree "Actual DOP",s.module,s.sql_id,s.event,s.status
from
gv$px_session px,
gv$session s
where
px.sid=s.sid (+) and
px.serial#=s.serial# and
px.inst_id = s.inst_id
order by 2 desc;
==============================
设置参数:
alter system set PARALLEL_MIN_TIME_THRESHOLD=1 scope=spfile;
alter system set PARALLEL_DEGREE_POLICY=auto scope=spfile;
shu immediate
startup
===================================
通过别的Session,查看状况: <<<<<<<<<<<<<<Requested DOP = 6 、 Actual DOP =6
SQL>@q00.sql
INST_ID Username QC/Slave Slave Set SID QC SID Requested DOP Actual DOP MODULE SQL_ID EVENT STATUS
---------- ------------ ---------- ---------- ---------- ------ ------------- ---------- ---------- -------------------- ------------------------- ------------------------
1 U1 QC 125 125 SQL*Plus 9y3cpa2z9r4zw SQL*Net message from clie INACTIVE
1 - p011 (Slave) 2 19 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p010 (Slave) 2 144 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p009 (Slave) 2 33 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p008 (Slave) 2 142 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p007 (Slave) 2 20 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p006 (Slave) 2 139 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p005 (Slave) 1 18 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p004 (Slave) 1 29 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p003 (Slave) 1 143 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p002 (Slave) 1 141 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p001 (Slave) 1 21 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p000 (Slave) 1 140 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
13行が選択されました。
SQL>
===================================
修改session 级别并行度,再次确认:
alter session force parallel query parallel 3;
select * from dba_segments,dba_extents;
===================================
通过别的Session,查看状况: <<<<< Requested DOP =3 Actual DOP =3
SQL>@q00.sql
INST_ID Username QC/Slave Slave Set SID QC SID Requested DOP Actual DOP MODULE SQL_ID EVENT STATUS
---------- ------------ ---------- ---------- ---------- ------ ------------- ---------- ---------- -------------------- ------------------------- ------------------------
1 U1 QC 125 125 SQL*Plus 9y3cpa2z9r4zw SQL*Net message from clie INACTIVE
1 - p005 (Slave) 2 20 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p004 (Slave) 2 21 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p003 (Slave) 2 144 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p002 (Slave) 1 140 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p001 (Slave) 1 19 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p000 (Slave) 1 148 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
SQL>
===================================
修改session 级别并行度,再次确认:
alter session force parallel query parallel 8;
select * from dba_segments,dba_extents;
===================================
通过别的Session,查看状况: <<<<< Requested DOP = 8 Actual DOP =8
INST_ID Username QC/Slave Slave Set SID QC SID Requested DOP Actual DOP MODULE SQL_ID EVENT STATUS
---------- ------------ ---------- ---------- ---------- ------ ------------- ---------- ---------- -------------------- ------------------------- ------------------------
1 U1 QC 125 125 SQL*Plus 9y3cpa2z9r4zw SQL*Net message from clie INACTIVE
1 - p015 (Slave) 2 153 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p014 (Slave) 2 23 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p013 (Slave) 2 154 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p012 (Slave) 2 29 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p011 (Slave) 2 18 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p010 (Slave) 2 141 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p009 (Slave) 2 33 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p008 (Slave) 2 142 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p007 (Slave) 1 31 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p006 (Slave) 1 139 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p005 (Slave) 1 21 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p004 (Slave) 1 20 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p003 (Slave) 1 144 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p002 (Slave) 1 148 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p001 (Slave) 1 26 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p000 (Slave) 1 143 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
SQL>
可以通过如下的脚本,来查看要求的并行度,和实际获得的并行度。
脚本来自:
http://askdba.org/weblog/forums/topic/query-to-identify-parallel-slaves/
col username for a12
col module for a10 trunc
col state for a20
col "QC SID" for A6
col SID for a10
col "QC/Slave" for A10
col "ReqDOP" for 999
col "ActDOP" for 999
col "slave set" for A10
col event for a25 trunc
col action for a20 trunc
col p1text for a20 trunc
col secwait for 99999
col state for a10 trunc
col object for a25 trunc
col command for a15 trunc
set pages 300 lines 300
select
s.inst_id,
decode(px.qcinst_id,NULL,s.username,
' - '||lower(substr(s.program,length(s.program)-4,4) ) ) "Username",
decode(px.qcinst_id,NULL, 'QC', '(Slave)') "QC/Slave" ,
to_char( px.server_set) "Slave Set",
to_char(s.sid) "SID",
decode(px.qcinst_id, NULL ,to_char(s.sid) ,px.qcsid) "QC SID",
px.req_degree "Requested DOP",
px.degree "Actual DOP",s.module,s.sql_id,s.event,s.status
from
gv$px_session px,
gv$session s
where
px.sid=s.sid (+) and
px.serial#=s.serial# and
px.inst_id = s.inst_id
order by 2 desc;
在Oracel 11.2.0.4进行实际测试,有效。
实际例子:
$cat q00.sql
col username for a12
col module for a10 trunc
col state for a20
col "QC SID" for A6
col SID for a10
col "QC/Slave" for A10
col "ReqDOP" for 999
col "ActDOP" for 999
col "slave set" for A10
col event for a25 trunc
col action for a20 trunc
col p1text for a20 trunc
col secwait for 99999
col state for a10 trunc
col object for a25 trunc
col command for a15 trunc
set pages 300 lines 300
select
s.inst_id,
decode(px.qcinst_id,NULL,s.username,
' - '||lower(substr(s.program,length(s.program)-4,4) ) ) "Username",
decode(px.qcinst_id,NULL, 'QC', '(Slave)') "QC/Slave" ,
to_char( px.server_set) "Slave Set",
to_char(s.sid) "SID",
decode(px.qcinst_id, NULL ,to_char(s.sid) ,px.qcsid) "QC SID",
px.req_degree "Requested DOP",
px.degree "Actual DOP",s.module,s.sql_id,s.event,s.status
from
gv$px_session px,
gv$session s
where
px.sid=s.sid (+) and
px.serial#=s.serial# and
px.inst_id = s.inst_id
order by 2 desc;
==============================
设置参数:
alter system set PARALLEL_MIN_TIME_THRESHOLD=1 scope=spfile;
alter system set PARALLEL_DEGREE_POLICY=auto scope=spfile;
shu immediate
startup
===================================
通过别的Session,查看状况: <<<<<<<<<<<<<<Requested DOP = 6 、 Actual DOP =6
SQL>@q00.sql
INST_ID Username QC/Slave Slave Set SID QC SID Requested DOP Actual DOP MODULE SQL_ID EVENT STATUS
---------- ------------ ---------- ---------- ---------- ------ ------------- ---------- ---------- -------------------- ------------------------- ------------------------
1 U1 QC 125 125 SQL*Plus 9y3cpa2z9r4zw SQL*Net message from clie INACTIVE
1 - p011 (Slave) 2 19 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p010 (Slave) 2 144 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p009 (Slave) 2 33 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p008 (Slave) 2 142 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p007 (Slave) 2 20 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p006 (Slave) 2 139 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p005 (Slave) 1 18 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p004 (Slave) 1 29 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p003 (Slave) 1 143 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p002 (Slave) 1 141 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p001 (Slave) 1 21 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p000 (Slave) 1 140 125 6 6 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
13行が選択されました。
SQL>
===================================
修改session 级别并行度,再次确认:
alter session force parallel query parallel 3;
select * from dba_segments,dba_extents;
===================================
通过别的Session,查看状况: <<<<< Requested DOP =3 Actual DOP =3
SQL>@q00.sql
INST_ID Username QC/Slave Slave Set SID QC SID Requested DOP Actual DOP MODULE SQL_ID EVENT STATUS
---------- ------------ ---------- ---------- ---------- ------ ------------- ---------- ---------- -------------------- ------------------------- ------------------------
1 U1 QC 125 125 SQL*Plus 9y3cpa2z9r4zw SQL*Net message from clie INACTIVE
1 - p005 (Slave) 2 20 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p004 (Slave) 2 21 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p003 (Slave) 2 144 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p002 (Slave) 1 140 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p001 (Slave) 1 19 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p000 (Slave) 1 148 125 3 3 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
SQL>
===================================
修改session 级别并行度,再次确认:
alter session force parallel query parallel 8;
select * from dba_segments,dba_extents;
===================================
通过别的Session,查看状况: <<<<< Requested DOP = 8 Actual DOP =8
INST_ID Username QC/Slave Slave Set SID QC SID Requested DOP Actual DOP MODULE SQL_ID EVENT STATUS
---------- ------------ ---------- ---------- ---------- ------ ------------- ---------- ---------- -------------------- ------------------------- ------------------------
1 U1 QC 125 125 SQL*Plus 9y3cpa2z9r4zw SQL*Net message from clie INACTIVE
1 - p015 (Slave) 2 153 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p014 (Slave) 2 23 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p013 (Slave) 2 154 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p012 (Slave) 2 29 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p011 (Slave) 2 18 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p010 (Slave) 2 141 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p009 (Slave) 2 33 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p008 (Slave) 2 142 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq: Execution Msg INACTIVE
1 - p007 (Slave) 1 31 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p006 (Slave) 1 139 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p005 (Slave) 1 21 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p004 (Slave) 1 20 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p003 (Slave) 1 144 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p002 (Slave) 1 148 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p001 (Slave) 1 26 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
1 - p000 (Slave) 1 143 125 8 8 SQL*Plus 9y3cpa2z9r4zw PX Deq Credit: send blkd ACTIVE
SQL>
相关文章推荐
- [Oracle运维工程师手记] 如何从trace 文件,判断是否执行了并行
- 如何取得Oracle并行执行的trace
- 在性能测试时,如何观察服务器端Oracle在执行的Sql语句
- 在性能测试时,如何观察服务器端Oracle在执行的Sql语句【监控】
- oracle如何获得客户端sql执行计划以便优化sql(三)
- 如何得到JDBC Insert 语句执行后插入Oracle 数据库记录的主键
- 如何看懂ORACLE执行计划
- Oracle模糊查询之(2.如何测试模糊查询的时间及使用是否使用索引)反向索引与模糊查询
- 如何看懂ORACLE执行计划
- ORACLE 的并行执行
- oracle如何产生sql 执行计划(一)
- ORCLE-Select 语句执行顺序以及如何提高Oracle 基本查询效率
- Oracle执行计划——处理一种并行hint不生效的情况
- 如何看懂ORACLE执行计划
- oracle如何分析sql执行计划
- Oracle如何查看SQL实际执行计划
- ORCLE-Select 语句执行顺序以及如何提高Oracle 基本查询效率
- 如何在ORACLE启动时执行一个自定义的存储过程
- 在sqldeveloper.exe中,如何执行oracle sql语句
- Select 语句执行顺序以及如何提高Oracle 基本查询效率