`

PARALLEL Related Hint

 
阅读更多

PARALLEL Hint

Note on Parallel Hints 

Beginning with Oracle Database 11g Release 2 (11.2.0.1), the PARALLEL and NO_PARALLEL hints are statement-level hints and supersede the earlier object-level hints: PARALLEL_INDEX, NO_PARALLEL_INDEX, and previously specified PARALLEL and NO_PARALLEL hints. For PARALLEL, if you specify integer, then that degree of parallelism will be used for the statement. If you omit integer, then the database computes the degree of parallelism. All the access paths that can use parallelism will use the specified or computed degree of parallelism.

In the syntax diagrams below, parallel_hint_statement shows the syntax for statement-level hints, and parallel_hint_object shows the syntax for object-level hints. Object-level hints are supported for backward compatibility, and are superseded by statement-level hints.

parallel_hint_statement::=

Description of parallel_hint_statement.gif follows
Description of the illustration parallel_hint_statement.gif

parallel_hint_object::=

Description of parallel_hint_object.gif follows
Description of the illustration parallel_hint_object.gif

(See "Specifying a Query Block in a Hint", tablespec::=)

The PARALLEL hint instructs the optimizer to use the specified number of concurrent servers for a parallel operation. This hint overrides the value of the PARALLEL_DEGREE_POLICY initialization parameter. The hint applies to the SELECT, INSERT, MERGE, UPDATE, and DELETE portions of a statement, as well as to the table scan portion. If any parallel restrictions are violated, then the hint is ignored.

Note:

The number of servers that can be used is twice the value in the PARALLEL hint, if sorting or grouping operations also take place.

For a statement-level PARALLEL hint:

  • PARALLEL: The statement always is run parallel, and the database computes the degree of parallelism, which can be 2 or greater.

  • PARALLEL (DEFAULT): The optimizer calculates a degree of parallelism equal to the number of CPUs available on all participating instances times the value of the PARALLEL_THREADS_PER_CPU initialization parameter.

  • PARALLEL (AUTO): The database computes the degree of parallelism, which can be 1 or greater. If the computed degree of parallelism is 1, then the statement runs serially.

  • PARALLEL (MANUAL): The optimizer is forced to use the parallel settings of the objects in the statement.
    Note: when use parallel(manual) hint and parallel_degree_policy=auto, the sql statement would be queued when the available parallel slaves is equal to or greater than parallel_servers_target. The parallel slaves won't exceed paralle_max_servers. Besides parallel(manual) hint would override
    parallel_min_time_thredshold parameter. And the statement DOP is determined by dictionary DOP.

  • PARALLEL (integer): The optimizer uses the degree of parallelism specified by integer.

In the following example, the optimizer calculates the degree of parallelism. The statement always runs in parallel.

SELECT /*+ PARALLEL */ last_name
  FROM employees;

In the following example, the optimizer calculates the degree of parallelism, but that degree may be 1, in which case the statement will run serially.

SELECT /*+ PARALLEL (AUTO) */ last_name
  FROM employees;

In the following example, the PARALLEL hint advises the optimizer to use the degree of parallelism currently in effect for the table itself, which is 5:

CREATE TABLE parallel_table (col1 number, col2 VARCHAR2(10)) PARALLEL 5; 

SELECT /*+ PARALLEL (MANUAL) */ col2
  FROM parallel_table;

For an object-level PARALLEL hint:

  • PARALLEL: The query coordinator should examine the settings of the initialization parameters to determine the default degree of parallelism.

  • PARALLEL (integer): The optimizer uses the degree of parallelism specified by integer.

  • PARALLEL (DEFAULT): The optimizer calculates a degree of parallelism equal to the number of CPUs available on all participating instances times the value of the PARALLEL_THREADS_PER_CPU initialization parameter.

In the following example, the PARALLEL hint overrides the degree of parallelism specified in the employees table definition:

SELECT /*+ FULL(hr_emp) PARALLEL(hr_emp, 5) */ last_name
  FROM employees hr_emp;

In the next example, the PARALLEL hint overrides the degree of parallelism specified in the employees table definition and instructs the optimizer to calculate a degree of parallelism equal to the number of CPUs available on all participating instances times the value of the PARALLEL_THREADS_PER_CPU initialization parameter.

SELECT /*+ FULL(hr_emp) PARALLEL(hr_emp, DEFAULT) */ last_name
  FROM employees hr_emp;

Oracle ignores parallel hints on temporary tables. Refer to CREATE TABLE and Oracle Database Concepts for more information on parallel execution.

See Also:

PARALLEL_INDEX Hint

Description of parallel_index_hint.gif follows
Description of the illustration parallel_index_hint.gif

(See "Specifying a Query Block in a Hint", tablespec::=, indexspec::=)

The PARALLEL_INDEX hint instructs the optimizer to use the specified number of concurrent servers to parallelize index range scans, full scans, and fast full scans for partitioned indexes.

The integer value indicates the degree of parallelism for the specified index. Specifying DEFAULT or no value signifies that the query coordinator should examine the settings of the initialization parameters to determine the default degree of parallelism. For example, the following hint indicates three parallel execution processes are to be used:

SELECT /*+ PARALLEL_INDEX(table1, index1, 3) */

See Also:

"Note on Parallel Hints" for more information on the parallel hints

PQ_DISTRIBUTE Hint

Description of pq_distribute_hint.gif follows

 

The PQ_DISTRIBUTE hint instructs the optimizer how to distribute rows among producer and consumer query servers. You can control the distribution of rows for either joins or for load.

 

Control of Distribution for Load You can control the distribution of rows for parallel INSERT ... SELECT and parallel CREATE TABLE ... AS SELECT statements to direct how rows should be distributed between the producer (query) and the consumer (load) servers. Use the upper branch of the syntax by specifying a single distribution method. The values of the distribution methods and their semantics are described in Table 3-22.

 

Table 3-22 Distribution Values for Load

Distribution Description

NONE

No distribution. That is the query and load operation are combined into each query server. All servers will load all partitions. This lack of distribution is useful to avoid the overhead of distributing rows where there is no skew. Skew can occur due to empty segments or to a predicate in the statement that filters out all rows evaluated by the query. If skew occurs due to using this method, then use either RANDOM or RANDOM_LOCAL distribution instead.

Note: Use this distribution with care. Each partition loaded requires a minimum of 512 KB per process of PGA memory. If you also use compression, then approximately 1.5 MB of PGA memory is consumer per server.

PARTITION

This method uses the partitioning information of tablespec to distribute the rows from the query servers to the load servers. Use this distribution method when it is not possible or desirable to combine the query and load operations, when the number of partitions being loaded is greater than or equal to the number of load servers, and the input data will be evenly distributed across the partitions being loaded—that is, there is no skew.

RANDOM

This method distributes the rows from the producers in a round-robin fashion to the consumers. Use this distribution method when the input data is highly skewed.

RANDOM_LOCAL

This method distributes the rows from the producers to a set of servers that are responsible for maintaining a given set of partitions. Two or more servers can be loading the same partition, but no servers are loading all partitions. Use this distribution method when the input data is skewed and combining query and load operations is not possible due to memory constraints.

 

For example, in the following direct-load insert operation, the query and load portions of the operation are combined into each query server:

 

INSERT /*+ APPEND PARALLEL(target_table, 16) PQ_DISTRIBUTE(target_table, NONE) */
  INTO target_table
  SELECT * FROM source_table;
 

 

In the following table creation example, the optimizer uses the partitioning of target_table to distribute the rows:

 

CREATE /*+ PQ_DISTRIBUTE(target_table, PARTITION) */ TABLE target_table
  NOLOGGING PARALLEL 16
  PARTITION BY HASH (l_orderkey) PARTITIONS 512
  AS SELECT * FROM source_table; 

 

Control of Distribution for Joins You control the distribution method for joins by specifying two distribution methods, as shown in the lower branch of the syntax diagram, one distribution for the outer table and one distribution for the inner table.

 

  • outer_distribution is the distribution for the outer table.

  • inner_distribution is the distribution for the inner table.

 

The values of the distributions are HASH, BROADCAST, PARTITION, and NONE. Only six combinations table distributions are valid, as described in Table 3-23:

 

Table 3-23 Distribution Values for Joins

Distribution Description

HASH, HASH

The rows of each table are mapped to consumer query servers, using a hash function on the join keys. When mapping is complete, each query server performs the join between a pair of resulting partitions. This distribution is recommended when the tables are comparable in size and the join operation is implemented by hash-join or sort merge join.

BROADCAST, NONE

All rows of the outer table are broadcast to each query server. The inner table rows are randomly partitioned. This distribution is recommended when the outer table is very small compared with the inner table. As a general rule, use this distribution when the inner table size multiplied by the number of query servers is greater than the outer table size.

NONE, BROADCAST

All rows of the inner table are broadcast to each consumer query server. The outer table rows are randomly partitioned. This distribution is recommended when the inner table is very small compared with the outer table. As a general rule, use this distribution when the inner table size multiplied by the number of query servers is less than the outer table size.

PARTITION, NONE

The rows of the outer table are mapped using the partitioning of the inner table. The inner table must be partitioned on the join keys. This distribution is recommended when the number of partitions of the outer table is equal to or nearly equal to a multiple of the number of query servers; for example, 14 partitions and 15 query servers.

Note: The optimizer ignores this hint if the inner table is not partitioned or not equijoined on the partitioning key.

NONE, PARTITION

The rows of the inner table are mapped using the partitioning of the outer table. The outer table must be partitioned on the join keys. This distribution is recommended when the number of partitions of the outer table is equal to or nearly equal to a multiple of the number of query servers; for example, 14 partitions and 15 query servers.

Note: The optimizer ignores this hint if the outer table is not partitioned or not equijoined on the partitioning key.

NONE, NONE

Each query server performs the join operation between a pair of matching partitions, one from each table. Both tables must be equipartitioned on the join keys.

 

For example, given two tables r and s that are joined using a hash join, the following query contains a hint to use hash distribution:

 

SELECT /*+ORDERED PQ_DISTRIBUTE(s HASH, HASH) USE_HASH (s)*/ column_list
  FROM r,s
  WHERE r.c=s.c;

 

To broadcast the outer table r, the query is:

 

SELECT /*+ORDERED PQ_DISTRIBUTE(s BROADCAST, NONE) USE_HASH (s) */ column_list
  FROM r,s
  WHERE r.c=s.c;

 

参考至:http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements006.htm#SQLRF50907

如有错误,欢迎指正

邮箱:czmcj@163.com

分享到:
评论

相关推荐

    oracle_hint教程汇总

    14. **HINT_DIRECT_PATH_INSERT** 和 **HINT_PARALLEL_INSERT**:这些Hint用于控制数据插入的方式,包括直接路径插入和并行插入。 15. **OUTLINE**:Outline是保存Hint的一种方式,它可以帮助在多个查询中重用相同...

    C#并发实战记录之Parallel.ForEach使用

    C#并发实战记录之Parallel.ForEach使用 本篇文章主要介绍了C#并发实战记录之Parallel.ForEach使用的相关知识点。通过示例代码,详细介绍了Parallel.ForEach的使用方法和优化技巧。 一、使用Parallel.ForEach优化...

    parallel-studio-a.lic

    标题中的"parallel-studio-a.lic"通常是指Intel Parallel Studio软件的一个许可证文件。Intel Parallel Studio是一套集成的开发工具,专为优化、调试和分析在多核处理器和并行系统上运行的C++、Fortran和C代码而设计...

    Parallel I/O for Cluster Computing

    Parallel I/O for Cluster Computing Foreword Introduction Part One - Cluster Computing... Appendix 2 - Selected Web Sites Related to I/O Index List of Figures List of Tables List of Examples

    MATLAB Parallel Computing Toolbox官方教程

    《MATLAB Parallel Computing Toolbox官方教程》是针对MATLAB 2017b版本的一个重要扩展工具箱,专门用于实现并行计算。这个教程包含了全面的用户手册和系统管理指南,帮助用户充分利用多核处理器、GPU(图形处理单元...

    Intel Parallel Studio XE 2011 序列号

    在探讨Intel Parallel Studio XE 2011序列号及相关信息之前,首先需要明确的是,序列号、许可证密钥等信息涉及软件版权和合法使用问题,任何未经授权的分享或使用都可能违反Intel的版权政策及法律法规。因此,本文...

    Intel Parallel Studio XE 2018 license

    《Intel Parallel Studio XE 2018许可证详解》 Intel Parallel Studio XE 2018是一款由Intel公司推出的高效能开发工具套件,它专为提升并行计算性能而设计,尤其针对多核处理器和多线程编程。这款工具集包含了一...

    Parallel Computer Architecture - A Hardware Software Approach

    The most exciting development in parallel computer architecture is the convergence of traditionally disparate approaches on a common machine structure. This book explains the forces behind this ...

    Intel Parallel Studio XE 2015 Update 5 Professional

    **Intel Parallel Studio XE 2015 Update 5 Professional Edition** 是一款由Intel公司推出的高效能计算开发工具集,专为提升并行编程效率而设计。该版本是2015年发布的一个更新,主要面向专业开发者,旨在优化和...

    Parallel Programming with Python

    Starting with the basics of parallel programming, you will proceed to learn about how to build parallel algorithms and their implementation. You will then gain the expertise to evaluate problem ...

    intel parallel studio xe 2013 license file

    《Intel Parallel Studio XE 2013 许可文件详解》 Intel Parallel Studio XE 是一套由Intel公司推出的高效能编程工具套件,专为提升并行计算性能而设计。2013版本是其在当时的重要产品,集成了编译器、调试器、性能...

    Wrox.Parallel.Programming.with.Intel.Parallel.Studio.XE.2012

    Optimize code for multi-core processors with Intel’s Parallel Studio Parallel programming is rapidly becoming a “must-know” skill for developers. Yet, where to start? This teach-yourself tutorial ...

    parallel_studio License.rar

    标题中的"parallel_studio License.rar"表明这是一个与Intel Parallel Studio相关的授权文件,它通常包含用于激活Intel编译器和其他开发工具的许可证密钥。Intel Parallel Studio是一款由Intel公司提供的集成开发...

    如何:编写 parallel_for 循环.doc

    编写 parallel_for 循环 Parallel_for 循环是并发编程中的一个重要概念,用于并行执行循环体中的任务以提高程序的执行效率。在本文中,我们将详细介绍如何编写 parallel_for 循环,並讨论其在矩阵乘法操作中的应用...

    oracle的Parallel_并行技术案例详解

    Oracle 的 Parallel 并行技术案例详解 Oracle 的 Parallel 并行技术是指在数据库系统中实现并行处理的技术,通过将一个大的任务分解成多个小的任务,并利用多个进程或线程来并发执行这些小任务,从而提高系统的处理...

    Parallel programming with Intel Parallel Studio XE code

    "Parallel programming with Intel Parallel Studio XE code" 指的是使用Intel Parallel Studio XE进行并行编程的相关代码示例。Intel Parallel Studio XE是一款由Intel公司提供的集成开发环境,专为优化并行计算而...

Global site tag (gtag.js) - Google Analytics