下面我通过实验介绍三种查看并行相关内容,比如并行度、并行执行的实例等。
1、V$PQ_TQSTAT视图
– 脚本
[oracle@rac1 ~]$ cat showdop.sql
column SERVER_TYPE format a15
column PROCESS format a10
select dfo_number,
tq_id,
server_type,
process,
num_rows,
bytes,
instance
from v$pq_tqstat
order by dfo_number desc,
tq_id,
server_type desc,
process
/
luocs@LUOCS11G> select /*+ parallel(2) */ count(*) from ltb1;
COUNT(*)
----------
3560448
luocs@LUOCS11G> @showdop
DFO_NUMBER TQ_ID SERVER_TYPE PROCESS NUM_ROWS BYTES INSTANCE
---------- ---------- --------------- ---------- ---------- ---------- ----------
1 0 Producer P000 1 32 1
1 0 Producer P001 1 32 1
1 0 Consumer QC 2 64 1
2、DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE
luocs@WWW> BEGIN
2 DBMS_SESSION.SET_IDENTIFIER('www.luocs.com');
3 DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE
4 (CLIENT_ID => 'www.luocs.com',
5 WAITS => TRUE
6 );
7 END;
8 /
PL/SQL procedure successfully completed.
luocs@WWW> select /*+ parallel(3) */ count(*) from test1;
COUNT(*)
----------
456128
luocs@WWW> exec DBMS_MONITOR.CLIENT_ID_TRACE_DISABLE('www.luocs.com');
PL/SQL procedure successfully completed.
sys@WWW> select client_identifier from v$session where sid=(select sid from v$mystat where rownum=1);
CLIENT_IDENTIFIER
----------------------------------------------------------------------------------------------------
www.luocs.com
sys@WWW> col PRIMARY_ID for a30
sys@WWW> select trace_type, primary_id, waits, binds from dba_enabled_traces;
TRACE_TYPE PRIMARY_ID WAITS BINDS
------------------------------------------ ------------------------------ ---------- ----------
CLIENT_ID www.luocs.com TRUE FALSE
[oracle@rac1 ~]$ cd /u01/app/oracle/diag/rdbms/www/ltb1/trace/
[oracle@rac1 trace]$ trcsess clientid=www.luocs.com output=luocs_test2.trc
[oracle@rac1 trace]$ ls luocs_test2.trc
-rw-r--r-- 1 oracle oinstall 103514 Jan 27 07:06 luocs_test2.trc