Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / Database concepts.pdf
Скачиваний:
29
Добавлен:
12.05.2015
Размер:
6.96 Mб
Скачать

How Parallel Execution Works

Note: When a set of parallel execution servers completes its operation, it moves on to operations higher in the data flow. For example, in the previous diagram, if there was another ORDER BY operation after the ORDER BY, then the parallel execution servers performing the table scan perform the second ORDER BY operation after completing the table scan.

Degree of Parallelism

The parallel execution coordinator may enlist two or more of the instance’s parallel execution servers to process a SQL statement. The number of parallel execution servers associated with a single operation is known as the degree of parallelism.

Note that the degree of parallelism applies directly only to intra-operation parallelism. If inter-operation parallelism is possible, the total number of parallel execution servers for a statement can be twice the specified degree of parallelism. No more than two sets of parallel execution servers can run simultaneously. Each set of parallel execution servers may process multiple operations. Only two sets of parallel execution servers need to be active to guarantee optimal inter-operation parallelism.

Parallel execution is designed to effectively use multiple CPUs and disks to answer queries quickly. When multiple users use parallel execution at the same time, it is easy to quickly exhaust available CPU, memory, and disk resources.

Oracle provides several ways to manage resource utilization in conjunction with parallel execution environments, including:

The adaptive multiuser algorithm, which reduces the degree of parallelism as the load on the system increases. You can turn this option with the PARALLEL_ ADAPTIVE_MULTI_USER parameter of the ALTER SYSTEM statement or in your initialization parameter file.

User resource limits and profiles, which allow you to set limits on the amount of various system resources available to each user as part of a user’s security domain.

The Database Resource Manager, which lets you allocate resources to different groups of users.

18-8 Oracle9i Database Concepts

How Parallel Execution Works

See Also:

Oracle9i Database Reference for information about PARALLEL_ ADAPTIVE_MULTI_USER

Oracle9i SQL Reference for the syntax of the ALTER SYSTEM SQL statement

Oracle9i Data Warehousing Guide

Parallel Query Intraand Inter-Operation Example

As an example of parallel query with intraand inter-operation parallelism, consider a more complex query:

SELECT /*+ PARALLEL(employees 4) PARALLEL(departments 4) USE_HASH(employees) ORDERED */

MAX(salary), AVG(salary) FROM employees, departments

WHERE employees.department_id = departments.department_id GROUP BY employees.department_id;

Note that hints have been used in the query to force the join order and join method, and to specify the degree of parallelism (DOP) of the tables employees and departments. In general, you should let the optimizer determine the order and method.

The query plan or data flow graph corresponding to this query is illustrated in Figure 18–4.

Parallel Execution of SQL Statements 18-9

How Parallel Execution Works

Figure 18–4 Data Flow Diagram for Joining Tables

Parallel

Execution

Coordinator

GROUP

BY

SORT

HASH

JOIN

FULL SCAN employees

FULL SCAN departments

Given two sets of parallel execution servers SS1 and SS2, the execution of this plan will proceed as follows: each server set (SS1 and SS2) will have four execution processes because of the PARALLEL hint in the query that specifies the DOP. In other words, the DOP will be four because each set of parallel execution servers will have four processes.

18-10 Oracle9i Database Concepts

How Parallel Execution Works

Slave set SS1 first scans the table employees while SS2 will fetch rows from SS1 and build a hash table on the rows. In other words, the parent servers in SS2 and the child servers in SS2 work concurrently: one in scanning employees in parallel, the other in consuming rows sent to it from SS1 and building the hash table for the hash join in parallel. This is an example of inter-operation parallelism.

After SS1 has finished scanning the entire table employees (that is, all granules or task units for employees are exhausted), it scans the table departments in parallel. It sends its rows to servers in SS2, which then perform the probes to finish the hash-join in parallel. After SS1 is done scanning the table departments in parallel and sending the rows to SS2, it switches to performing the GROUP BY in parallel. This is how two server sets run concurrently to achieve inter-operation parallelism across various operators in the query tree while achieving intra-operation parallelism in executing each operation in parallel.

Another important aspect of parallel execution is the re-partitioning of rows while they are sent from servers in one server set to another. For the query plan in Figure 18–4, after a server process in SS1 scans a row of employees, which server process of SS2 should it send it to? The partitioning of rows flowing up the query

tree is decided by the operator into which the rows are flowing into. In this case, the partitioning of rows flowing up from SS1 performing the parallel scan of employees into SS2 performing the parallel hash-join is done by hash partitioning on the join column value. That is, a server process scanning employees computes a hash function of the value of the column employees.employee_id to decide the number of the server process in SS2 to send it to. The partitioning method used in parallel queries is explicitly shown in the EXPLAIN PLAN of the query. Note that the partitioning of rows being sent between sets of execution servers should not be confused with Oracle’s partitioning feature whereby tables can be partitioned using hash, range, and other methods.

See Also: Oracle9i Data Warehousing Guide for examples of using

EXPLAIN PLAN with parallel query

Parallel Execution of SQL Statements 18-11

Соседние файлы в папке Oracle selected docs