zoukankan      html  css  js  c++  java
  • 如何测试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>

  • 相关阅读:
    Scrapy 使用 LinkExtractor 提取链接和使用 Exporter 导出数据
    Scrapy 使用 Item 封装数据、使用 Item Pipline处理数据
    XPath 和 CSS
    Scrapy 中的 Request 对象和 Respionse 对象
    Scrapy 框架结构及工作原理
    Scrapy 常用的shell执行命令
    mui html5 plus
    《C++ Primer》读书笔记—第二章 变量和基本类型
    eclipse+maven搭建ssm框架
    unique_ptr 智能指针(C++11)
  • 原文地址:https://www.cnblogs.com/gaojian/p/7568033.html
Copyright © 2011-2022 走看看