Oracle11gr2新增PARALLEL_FORCE_LOCAL引數

yangtingkun發表於2011-01-19

11.2以前,當使用者發出並行查詢,Oracle會將負載分配到所有的例項上,而在11.2中,Oracle提供了初始化引數,可以限制並行只執行在當前例項上。

RAC環境對並行查詢的支援:http://yangtingkun.itpub.net/post/468/468445

 

 

看一個簡單的例子:

SQL> select * from v$version;                 

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Solaris: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL> create table t                     
  2  as select a.*
  3  from dba_objects a;      

Table created.

SQL> insert into t
  2  select *
  3  from t;

72122 rows created.

SQL> insert into t
  2  select *
  3  from t;

144244 rows created.

SQL> insert into t
  2  select *
  3  from t;

288488 rows created.

SQL> commit;

Commit complete.

SQL> select count(*) from t;

  COUNT(*)
----------
    576976

下面在另外的會話檢查系統中並行程式的使用:

SQL> select * from gv$px_process;

   INST_ID SERV STATUS           PID SPID                            SID    SERIAL#
---------- ---- --------- ---------- ------------------------ ---------- ----------
         2 PZ99 IN USE            47 2568                            266       3388
         1 PZ99 IN USE            46 16790                            26       2657

下面設定會話級別的parallel_force_local引數:

SQL> show parameter parallel_force

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
parallel_force_local                 boolean     FALSE
SQL> alter session set parallel_force_local = true;

Session altered.

SQL> select /*+ parallel(4) */ count(*) from t;

  COUNT(*)
----------
    576976

檢查並行程式使用情況:

SQL> select * from gv$px_process;

   INST_ID SERV STATUS           PID SPID                            SID    SERIAL#
---------- ---- --------- ---------- ------------------------ ---------- ----------
         2 PZ99 IN USE            47 2568                            266       3416
         1 PZ99 IN USE            46 16790                            32       3928
         1 P003 AVAILABLE         52 22527
         1 P002 AVAILABLE         51 22519
         1 P001 AVAILABLE         45 22517
         1 P000 AVAILABLE         37 22515

6 rows selected.

可以看到,所有的並行都集中在例項1上,下面設定parallel_force_localfalse

SQL> alter session set parallel_force_local = false;

Session altered.

SQL> select /*+ parallel(4) */ count(*) from t;

  COUNT(*)
----------
    576976

再次檢查平行程式使用情況:

SQL> select * from gv$px_process;

   INST_ID SERV STATUS           PID SPID                            SID    SERIAL#
---------- ---- --------- ---------- ------------------------ ---------- ----------
         1 PZ99 IN USE            46 16790                            32       3932
         1 P003 AVAILABLE         52 22527
         1 P002 AVAILABLE         51 22519
         1 P001 AVAILABLE         45 22517
         1 P000 AVAILABLE         37 22515
         2 PZ99 IN USE            47 2568                            265        649
         2 P003 AVAILABLE         48 17432
         2 P002 AVAILABLE         46 17424
         2 P001 AVAILABLE         43 17413
         2 P000 AVAILABLE         40 17411

10 rows selected.

可以看到,並行這次分配到兩個例項上。

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-684317/,如需轉載,請註明出處,否則將追究法律責任。

相關文章