A parallel INSERT, UPDATE or DELETE runs as one query coordinator plus many slave sessions, and each slave has its own transaction. This lists the slaves of one coordinator with the undo each has used, so you can watch a big parallel DML make progress, or see whether one slave is doing all the work.
Usage
SQL> @pqslaves.sql 1234
The argument is the coordinator's SID. To check your own parallel statement, get your SID from another window first: select sid from v$mystat where rownum = 1;
-- pqslaves.sql: parallel slaves of one query coordinator, with the undo each has used
-- Copyright (c) HASHJOIN. MIT License (https://hashjoin.com/kb/license/)
-- https://hashjoin.com/kb/oracle/parallel-query-slaves/
--
-- Usage: @pqslaves.sql <coordinator_sid>
prompt get value for 1 from [select sid from v$mystat where rownum = 1;]
set lines 132
col TRANS_ID format a20
select a.sid, a.program, b.start_time, b.used_ublk,
b.xidusn ||'.'|| b.xidslot || '.' || b.xidsqn trans_id
from v$session a, v$transaction b
where a.taddr = b.addr
and a.sid in ( select sid from v$px_session where qcsid = &&1)
order by sid;curl -O https://hashjoin.com/kb/oracle/parallel-query-slaves/pqslaves.sql
Reading the output
One row per slave: SID, program (P000, P001…), transaction start time, USED_UBLK (undo blocks) and transaction ID. Run it a few times: USED_UBLK growing evenly across slaves means the work is spread well; one slave far ahead of the others means skew in how the rows were distributed.
Gotchas
- Only slaves with an open transaction appear, so it's for parallel DML. Slaves of a parallel query have no transaction and aren't listed.
- It reads
v$views, so on RAC it shows the slaves on the instance you're connected to.
What it reads
v$px_session v$transaction v$session
Related
Tired of fixing the same thing twice?
HASHJOIN turns the checks and fixes your on-call runs by hand into tooling that gives the same answer every time. Fixed scope, and you own all of the code.
New fixes and field notes by email, about once a month.