Oracle并行操作――并行DML操作 (二)

2014-11-24 09:23:51 · 作者: · 浏览: 1
ssion中的qcsid字段含义为“Session serial number of the parallel coordinator”,就是并行操作中扮演协调者角色的进程。

如果不使用并行收集,只是简单的串行收集,我们查看一下效率情况。

//指定串行

SQL> exec dbms_stats.gather_table_stats(user,'T',cascade => true,degree => 1);

PL/SQL procedure successfully completed

Executed in46.816seconds

效果清晰可见,从原来的15s多的收集时间,放大为47s左右,几乎是三倍的损耗。

结论:对于统计量收集而言,如果作业时间可以避开业务高峰时间窗口,进行并行操作收集统计量还是一个不错的选择。

3、并行insert操作

下面进行并行insert操作,我们选择使用hint来进行并行控制。

//开启PDML的开关

SQL> alter session enable parallel dml;

Session altered

Executed in 0.016 seconds

使用hint,开启8个并行度进行insert操作。

--并行insert

SQL>insert /*+ parallel(t,8) */ into t select * from t;

10039808 rows inserted

Executed in 76.238 seconds

运行过程中,出现的并行操作过程如下。

//开启8个并行度;

SQL> select * from v$px_session;

SADDR SID SERIAL# QCSID QCSERIAL#

---------------- ---------- ---------- ---------- ----------

070000007FFF52E0 361 3123 324 26152

070000007FE84950 176 50028 324 26152

070000007FE7EC70 178 35508 324 26152

070000007FE0AAF0 218 5994 324 26152

070000007D29D620 510 20829 324 26152

070000007D2A0490 509 26391 324 26152

070000007FC94480 35 50615 324 26152

070000007FFFAFC0 359 32516 324 26152

070000007D12FB00 324 26152 324

9 rows selected

SQL> select * from v$px_process;

SERVER_NAME STATUS PID SPID SID SERIAL#

----------- --------- ---------- ------------------------ ---------- ----------

P006 INUSE 100 19005590 35 50615

P001 INUSE 69 19398710 176 50028

P002 INUSE 73 9633968 178 35508

P003 INUSE 85 23068694 218 5994

P007 INUSE 102 18743298 359 32516

P000 INUSE 66 14221352 361 3123

P005 INUSE 99 21233884 509 26391

P004 INUSE 95 19071188 510 20829

8 rows selected

此时,我们尝试抽取出执行计划。

//从shared_pool中尝试获取到指定的记录;

SQL> select sql_text, sql_id, version_count from v$sqlarea where sql_text like 'insert /*+ parallel(t,8) */%';

SQL_TEXT SQL_ID VERSION_COUNT

-------------------------------------------------- ------------- -------------

insert /*+ parallel(t,8) */ into t select * from t 67wymm0jhw3gv 2

Executed in 0.234 seconds

利用sql_id,尝试抽取出shared_pool中的执行计划。

//抽取出执行计划,篇幅原因,有删节……

SQL> select * from table(dbms_xplan.display_cursor('67wymm0jhw3gv',format => 'advanced',cursor_child_no => 1));

PLAN_TABLE_OUTPUT

----------------------------------------------------------------------------------------------------

SQL_ID 67wymm0jhw3gv, child number 1

-------------------------------------

insert /*+ parallel(t,