Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle parallel hint tips

Oracle Database Tips by Donald BurlesonMarch 31, 2015

Question:  I want to understand how the parallel hint works inside a SQL statement and I also want to know the optimal degree for the parallel hint.  Are there rules for determining the optimal parallel hint degree?

Answer:  The parallel hint is one of the "good" hints, such as the cardinality and ordered hints.  There are several guidelines for using the parallel hint:

  • The target table or index must be doing a full-scan operation,

  • A starting point for the parallel degree us cpu_count-1 (the truly fastest degree is determined empirically via timing the query.  See optimizing the degree for a parallel hint

  • If the table is aliased, the parallel hint must also be aliased.

The parallel hint accepts a table name an an optional "degree" argument to tell Oracle how many factotum (slave) processes to use in the parallel hinted query:

Note:  For all OLTP databases, it is recommended to use parallel as a hint only and DO NOT turn-on parallelism at the table or system level:

alter table customer parallel degree 35; -- not recommended for OLTP

Setting parallel at the table level avoids the need to use hints, but it has the downside of causing the optimizer to start favoring full scan operations.

Examples of parallel hints

The recommended approach for using Parallel query is to add a parallel hint to all SQL statements that perform a full-table scan and would benefit from parallel query.

select /*+ FULL(emp) PARALLEL(emp, 35) */

Here is an example of a "bad" parallel hint because the parallel hint is with an index hint.  The following hint is invalid because first_rows access and parallel access are mutually exclusive. That is because parallel access always assumes a full-table scan and first_rows favors index access.

-- An invalid parallel hint
select /*+ first_rows_10 index (emp emp_idx) parallel(emp,8)*/
   emp_name
from
   emp
where
   emp_type = 'SALARIED';

This parallel hint is invalid because the table is aliased and the parallel hint does not use the alias:

-- An invalid parallel hint
select /*+ parallel(emp,8)*/
   emp_name
from
   emp e
where
   emp_type = 'SALARIED';

You can also have multiple parallel hints within a query.  The following example shows two parallel hints within a query, one for each table::

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;


Tuning with the parallel hint

When using parallel query, one should seldom turn on parallelism at the table level, alter table customer parallel 35, because the setting of parallelism for a table influences the optimizer.
 
This causes the optimizer to see that the full-table scan is inexpensive. Hence, most Oracle professionals specify parallel query on a query-by-query basis, combining the full hint with the parallel hint to ensure a fast parallel full-table scan:

-- A valid hint
select /*+ full parallel(emp,35)*/
emp_name
from
emp
order by
ename;

The number of processors dedicated to service a SQL request is ultimately determined by Oracle Query Manager, but the programmer can specify the upper limit on the number of simultaneous processes. When using the cost-based optimizer, the parallel hint can be embedded into the SQL to specify the number of processes. For instance:

select /*+ FULL(employee_table) PARALLEL(employee_table, 35) */
employee_name
from
employee_table
where
emp_type = 'SALARIED';

If you are using an SMP or MPP database server with many CPUs, you can issue a parallel request and leave it up to each Oracle instance to use its default degree of parallelism. For example:

select /*+ FULL(employee_table) PARALLEL(employee_table, DEFAULT, DEFAULT) */
employee_name
from
employee_table
where
emp_type = 'SALARIED';

In most cases, it is better for the Oracle Remote DBA to determine the optimal degree of parallelism and then set that degree in the data dictionary with the following command:

Alter table employee_table parallel degree 35;

This way, the Remote DBA can always be sure of the degree of parallelism for any particular table.

 

 

 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.

 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster