现在的位置: 首页 > 综合 > 正文

Oracle Parallel Query(OPQ)

2017年12月18日 ⁄ 综合 ⁄ 共 1754字 ⁄ 字号 评论关闭
     Oracle Parallel QueryOPQ)可以将一个SQL statement分成多个片(chunks),然后在独自的CPU上通过多个process进行并行运行。典型的应用是:full table scans, creating or rebuilding an index one or more partitions of an indexPartition operations such as moving or splitting partitionsCREATE TABLE AS SELECT   operations  if the SELECT involves a full table or partition scan INSERT INTO . . . SELECT operations, if the SELECT involves a full table or partition scan Update and delete operations on partitioned tablessorts, sub_queries, data loading.
      而另一个PARALLEL的概念是Parallel Server ClustersRAC),是利用Clustered 环境的multi-node来达到性能上的总体提高。通常用在一个非常大的数据库应用中。不在本次讨论之列。
一:INIT.ORA相关参数
PARALLEL_MIN_SERVERS
PARALLEL_MAX_SERVERS
PARALLEL_AUTOMATIC_TUNING=TRUE    ORACLE会尽量使用PARALLEL
二:OBJECT级启用OPQ
ALTER  TABLE /INDEX XXX PARALLEL DEGREE 8
OR
STATEMENT
SELECT   --+ PARALLEL table_alias, degree, nodes from table …..
/*+ FULL(emp) PARALLEL(table_alias, 35) */
三:表级停止OPQ
ALTER   TABLE/INDEX  XXX  PARALLEL DEGREE 1  INSTANCES 1
OR
ALTER  TABLE/INDEX  XXX   NOPARALLEL
四:INSTANCE
Alter table customer parallel degree 35;
五:局限
Paralle Query并不一定是最好的,尤其是武断的把所有TABLE都设置成Paralle Query更是危险的,因为CBO会改变评估标准而尽量使用parallel full-table scans而不是index scans。因为CBO认为parallel full-table scancostfull-table scan低,所以如果非要这么做,那么需要调整optimizer_index_cost_adj。此值默认是1000,如果调整为10则基本都会用INDEX,那么可以调整为小于1000的某个值,然后及时监控性能并再作调整。
相关数据字典
select * from v_$pq_sysstat;
select * from v_$px_process;
select * from v_$px_sesstat;
select * from v_$px_process_sysstat;
七:其他OPQ用法
SQLLDR   SQLLOAD scott/tiger CONTROL=con1.ctl DIRECT=TRUE PARALLEL=TRUE
Parallel Recovery 1RECOVERY_PARALLELISM
             2RECOVER TABLESPACE tab PARALLEL (DEGREE 4);
                RECOVER DATABASE PARALLEL (DEGREE DEFAULT);
八:名词解释
InstanceSpecifies the number of instances to use(除非在OPS环境,否则只需要设置为1,其他的都是无意义的)
DEGREE: Specifies the number of slave processes to use on each instance

抱歉!评论已关闭.