如何测试Oracle并行执行的并行度状况

简介:

如何测试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://www.cnblogs.com/gaojian/p/7568033.html,如需转载请自行联系原作者

目录
相关文章
|
4月前
|
存储 监控 API
Flink的每个key状态 和每个并行度的状态 怎么测试区分?
Flink的每个key状态 和每个并行度的状态 怎么测试区分?
35 0
|
1月前
|
存储 API 流计算
要测试和区分Flink的每个key状态和每个并行度的状态
【2月更文挑战第23天】要测试和区分Flink的每个key状态和每个并行度的状态
14 1
|
5月前
|
SQL 存储 Oracle
flink-cdc-oracle 可以并行读取吗
flink-cdc-oracle 可以并行读取吗, 同步1000万数据,我这边半天没同步完, 这个有什么优化策略吗?这个怎么设置先全量并行读,然后增量 是flink sql跑的?
56 1
|
10月前
|
人工智能 运维 Oracle
ChatGPT能代替Oracle DBA吗?用Oracle OCP(1z0-083)的真题测试一下(文末投票)
ChatGPT已经通过了很多考试,姚远老师是Oracle OCP和MySQL OCP讲师,我很好奇ChatGPT能不能通过Oracle OCP的考试呢?让我们拿Oracle 19c OCP考试(1z0-082)的真题对ChatGPT进行一个测试。
136 0
|
10月前
|
人工智能 运维 Oracle
ChatGPT能代替Oracle DBA吗?用Oracle OCP(1z0-083)的真题测试一下。
第1道题ChatGPT就做错了,姚远老师心里不禁窃喜,看来ChatGPT也不咋地,我们也许不会失业,让我们来看看第一道题的题目
121 0
|
11月前
|
Oracle 关系型数据库
|
11月前
|
Oracle 关系型数据库
|
11月前
|
SQL 监控 Oracle
Oracle优化08-并行执行
Oracle优化08-并行执行
70 0
|
11月前
|
SQL Oracle 关系型数据库
Oracle数据库管理员经典试题【Oracle基础知识测试】
Oracle数据库管理员经典试题【Oracle基础知识测试】
81 0
|
Oracle Java 关系型数据库
loadrunner 脚本开发-调用java jar文件远程操作Oracle数据库测试
loadrunner 脚本开发-调用java jar文件远程操作Oracle数据库测试
133 0

推荐镜像

更多