自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

詳解Oracle數(shù)據(jù)庫并行操作常見等待事件及腳本

數(shù)據(jù)庫 Oracle
今天主要介紹Oracle數(shù)據(jù)庫在并行操作過程中 slave 進(jìn)程和 QC 進(jìn)程經(jīng)常遇到的等待事件及常用腳本。

今天主要介紹Oracle數(shù)據(jù)庫在并行操作過程中 slave 進(jìn)程和 QC 進(jìn)程經(jīng)常遇到的等待事件及常用腳本。

一、PX Deq: Execution Msg,PX Deq: Execute Reply等待事件

1. PX Deq: Execution Msg

Occurs when a parallel slave is waiting to be told what to do. This is normally considered an idle event, but can cause excessive CPU in some cases.

該事件是并行查詢中的常見事件。當(dāng)PQ slave進(jìn)程在等待QC告訴它要做什么的時(shí)候就會(huì)出現(xiàn)此事件(eg: when waiting to be told parse / execute / fetch etc..)

v$session_wait 中該等待事件對(duì)應(yīng)的參數(shù):

  • P1 = sleeptime/senderid
  • P2 = passes
  • P3 = not used

我們可以使用如下語句獲取轉(zhuǎn)換sleeptime/senderid的相關(guān)信息:

  1. set SERVEROUTPUT on 
  2. undef p1 
  3. declare 
  4.  inst varchar(20); 
  5.  sender varchar(20); 
  6. begin 
  7.  select bitand(&&p1, 16711680) - 65535 as SNDRINST, 
  8.  decode(bitand(&&p1, 65535),65535, 'QC', 'P'||to_char(bitand(&&p1, 65535),'fm000') ) as SNDR 
  9.  into inst , sender 
  10.  from dual 
  11.  where bitand(&&p1, 268435456) = 268435456; 
  12.  dbms_output.put_line('Instance = '||inst); 
  13.  dbms_output.put_line('Sender = '||sender ); 
  14. end; 
  15. /  

如果P1的值為空,則意味slave 不需要等待任何進(jìn)程

比如p1的值為268501004,則上面的sql會(huì)返回:

  1. Instance = 1  
  2. Sender = P012 

passes 進(jìn)程在得到信息之前循環(huán)輪轉(zhuǎn)等待的次數(shù)

該等待事件是一個(gè)空閑等待事件,當(dāng)此等待事件出現(xiàn),進(jìn)程會(huì)持續(xù)等待并逐漸增加等待次數(shù)直到獲取信息!

解決方法:

作為 Coordinator 的 Process 在獲取 Slave 進(jìn)程的數(shù)據(jù)時(shí),反應(yīng)太慢了,導(dǎo)致某些 Slave進(jìn)行因?yàn)?Queue 滿而不得不等待,進(jìn)而拖慢了整個(gè)并行執(zhí)行的速度。

這常常是由于 CPU 數(shù)目不足或者 系統(tǒng)中運(yùn)行的 進(jìn)程太多導(dǎo)致。可考慮 減小并行度。

2. PX Deq: Execute Reply

Occurs when the query coordinator is waiting for a response from a parallel slave. This is normally considered an idle event, but can cause excessive CPU in some cases.

Waiting Process: QC

協(xié)調(diào)器正在等待一個(gè) 從slaves 進(jìn)程對(duì)控制信息的響應(yīng)(確認(rèn)通知)或者期望從slave進(jìn)程集中獲取數(shù)據(jù)。這個(gè)等待事件意味著QC等待slaves結(jié)束執(zhí)行sql 并且將結(jié)果集發(fā)送給QC

v$session_wait 中該等待事件對(duì)應(yīng)的參數(shù):

  • P1 = sleeptime/senderid
  • P2 = passes
  • P3 = not used

我們可以使用如下語句獲取轉(zhuǎn)換sleeptime/senderid的相關(guān)信息:

  1. set SERVEROUTPUT on 
  2. undef p1 
  3. declare 
  4.  inst varchar(20); 
  5.  sender varchar(20); 
  6. begin 
  7.  select bitand(&&p1, 16711680) - 65535 as SNDRINST, 
  8.  decode(bitand(&&p1, 65535),65535, 'QC', 'P'||to_char(bitand(&&p1, 65535),'fm000') ) as SNDR 
  9.  into inst , sender 
  10.  from dual 
  11.  where bitand(&&p1, 268435456) = 268435456; 
  12.  dbms_output.put_line('Instance = '||inst); 
  13.  dbms_output.put_line('Sender = '||sender ); 
  14. end; 
  15. /  

如果P1的值為空,則意味slave 不需要等待任何進(jìn)程

比如p1的值為268501004,則上面的sql會(huì)返回:

  1. Instance = 1 
  2. Sender = P012 

等待時(shí)間:這是非空閑等待時(shí)間,QC 等待從slave 的響應(yīng)或者查詢的數(shù)據(jù)結(jié)果

解決辦法:非優(yōu)化的sql語句肯能是導(dǎo)致此等待事件的原因:slaves 需要花費(fèi)很長(zhǎng)時(shí)間來執(zhí)行sql 語句而qc又在等待slave返回?cái)?shù)據(jù)。

優(yōu)化sql,查看slave 在執(zhí)行的語句以及其執(zhí)行計(jì)劃,并做出盡量的優(yōu)化,以便減少slave執(zhí)行sql語句的時(shí)間!

二、相關(guān)腳本

1. gives an overview of all running parallel queries with all slaves.It shows the if a slave is waiting and for what event it waits.

  1. select decode(px.qcinst_id, 
  2.  NULL, 
  3.  username, 
  4.  ' - ' || 
  5.  lower(substr(pp.SERVER_NAME, length(pp.SERVER_NAME) - 4, 4))) "Username", 
  6.  decode(px.qcinst_id, NULL, 'QC', '(Slave)') "QC/Slave", 
  7.  to_char(px.server_set) "SlaveSet", 
  8.  to_char(s.sid) "SID", 
  9.  to_char(px.inst_id) "Slave INST", 
  10.  decode(sw.state, 'WAITING', 'WAIT', 'NOT WAIT') as STATE, 
  11.  case sw.state 
  12.  WHEN 'WAITING' THEN 
  13.  substr(sw.event, 1, 30) 
  14.  ELSE 
  15.  NULL 
  16.  end as wait_event, 
  17.  decode(px.qcinst_id, NULL, to_char(s.sid), px.qcsid) "QC SID", 
  18.  to_char(px.qcinst_id) "QC INST", 
  19.  px.req_degree "Req. DOP", 
  20.  px.degree "Actual DOP" 
  21.  from gv$px_session px, gv$session s, gv$px_process pp, gv$session_wait sw 
  22.  where px.sid = s.sid(+) 
  23.  and px.serial# = s.serial#(+) 
  24.  and px.inst_id = s.inst_id(+) 
  25.  and px.sid = pp.sid(+) 
  26.  and px.serial# = pp.serial#(+) 
  27.  and ssw.sid = s.sid 
  28.  and ssw.inst_id = s.inst_id 
  29.  order by decode(px.QCINST_ID, NULL, px.INST_ID, px.QCINST_ID), 
  30.  px.QCSID, 
  31.  decode(px.SERVER_GROUP, NULL, 0, px.SERVER_GROUP), 
  32.  px.SERVER_SET, 
  33.  px.INST_ID / 

詳解Oracle數(shù)據(jù)庫并行操作常見等待事件及腳本

2. shows for the PX Deq events the processes that are exchange data.

  1. select sw.SID as RCVSID, 
  2.  decode(pp.server_name, NULL, 'A QC', pp.server_name) as RCVR, 
  3.  sw.inst_id as RCVRINST, 
  4.  case sw.state 
  5.  WHEN 'WAITING' THEN 
  6.  substr(sw.event, 1, 30) 
  7.  ELSE 
  8.  NULL 
  9.  end as wait_event, 
  10.  decode(bitand(p1, 65535), 
  11.  65535, 
  12.  'QC', 
  13.  'P' || to_char(bitand(p1, 65535), 'fm000')) as SNDR, 
  14.  bitand(p1, 16711680) - 65535 as SNDRINST, 
  15.  decode(bitand(p1, 65535), 
  16.  65535, 
  17.  ps.qcsid, 
  18.  (select sid 
  19.  from gv$px_process 
  20.  where server_name = 
  21.  'P' || to_char(bitand(sw.p1, 65535), 'fm000') 
  22.  and inst_id = bitand(sw.p1, 16711680) - 65535)) as SNDRSID, 
  23.  decode(sw.state, 'WAITING', 'WAIT', 'NOT WAIT') as STATE 
  24.  from gv$session_wait sw, gv$px_process pp, gv$px_session ps 
  25.  where sw.sid = pp.sid(+) 
  26.  and sw.inst_id = pp.inst_id(+) 
  27.  and sw.sid = ps.sid(+) 
  28.  and sw.inst_id = ps.inst_id(+) 
  29.  and p1text = 'sleeptime/senderid' 
  30.  and bitand(p1, 268435456) = 268435456 
  31.  order by decode(ps.QCINST_ID, NULL, ps.INST_ID, ps.QCINST_ID), 
  32.  ps.QCSID, 
  33.  decode(ps.SERVER_GROUP, NULL, 0, ps.SERVER_GROUP), 
  34.  ps.SERVER_SET, 
  35.  ps.INST_ID 

詳解Oracle數(shù)據(jù)庫并行操作常見等待事件及腳本

3. shows for long running processes what are the slaves do.

  1. select decode(px.qcinst_id, 
  2.  NULL, 
  3.  username, 
  4.  ' - ' || 
  5.  lower(substr(pp.SERVER_NAME, length(pp.SERVER_NAME) - 4, 4))) "Username", 
  6.  decode(px.qcinst_id, NULL, 'QC', '(Slave)') "QC/Slave", 
  7.  to_char(px.server_set) "SlaveSet", 
  8.  to_char(px.inst_id) "Slave INST", 
  9.  substr(opname, 1, 30) operation_name, 
  10.  substr(target, 1, 30) target, 
  11.  sofar, 
  12.  totalwork, 
  13.  units, 
  14.  start_time, 
  15.  timestamp, 
  16.  decode(px.qcinst_id, NULL, to_char(s.sid), px.qcsid) "QC SID", 
  17.  to_char(px.qcinst_id) "QC INST" 
  18.  from gv$px_session px, gv$px_process pp, gv$session_longops s 
  19.  where px.sid = s.sid 
  20.  and px.serial# = s.serial# 
  21.  and px.inst_id = s.inst_id 
  22.  and px.sid = pp.sid(+) 
  23.  and px.serial# = pp.serial#(+) 
  24.  order by decode(px.QCINST_ID, NULL, px.INST_ID, px.QCINST_ID), 
  25.  px.QCSID, 
  26.  decode(px.SERVER_GROUP, NULL, 0, px.SERVER_GROUP), 
  27.  px.SERVER_SET, 
  28.  px.INST_ID 

詳解Oracle數(shù)據(jù)庫并行操作常見等待事件及腳本

責(zé)任編輯:趙寧寧 來源: 今日頭條
相關(guān)推薦

2009-09-02 18:52:38

Oracle數(shù)據(jù)庫并行

2010-04-07 14:22:46

2010-04-27 10:39:59

Oracle數(shù)據(jù)庫

2011-05-25 09:45:40

Oracle數(shù)據(jù)庫

2010-04-02 16:13:38

Oracle 數(shù)據(jù)庫

2009-07-23 09:31:56

數(shù)據(jù)庫表連接方式

2019-08-29 10:17:42

OracleKfkTOP N

2011-05-19 13:25:14

Oracle數(shù)據(jù)庫

2017-12-04 15:28:36

數(shù)據(jù)庫Oracle等待事件

2017-11-30 07:30:21

數(shù)據(jù)庫Oracle等待事件

2017-10-25 08:56:01

數(shù)據(jù)庫Oracle等待事件

2010-04-02 13:59:08

Oracle數(shù)據(jù)庫

2010-04-14 15:14:11

Oracle數(shù)據(jù)庫

2011-03-29 10:47:49

ORACLE數(shù)據(jù)庫

2010-04-09 14:48:41

Oracle數(shù)據(jù)庫

2010-04-09 14:37:08

Oracle數(shù)據(jù)庫

2009-03-16 13:30:55

腳本數(shù)據(jù)字典Oracle

2011-07-26 16:05:19

Oracle數(shù)據(jù)庫服務(wù)器

2011-05-17 15:02:15

ORACLE數(shù)據(jù)庫備份

2011-08-18 15:49:21

Oracle厲行計(jì)劃
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)