Wednesday, 18 March 2015

Parallel Execution of SQL Statements

Parallelism is the idea of breaking down a task so that, instead of one process doing all of the work in a query, many processes do part of the work at the same time.
SQL Operations that can be parallelized.
  • Parallel Query
  • Parallel DDL (Can't be used on the tables with Object or LOB type columns)
  • Parallel DML
  • SQL * Loader


Degree of Parallelism :
The number of parallel execution servers associated with a single operation is known as the Degree of parallelism.
Example:
With Select Statement
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;

With SQL Loader :
Available with Direct path data loads only 
$sqlldr control=emp.ctl parallel=true direct=true 




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.

No comments:

Post a Comment