In my previous articles I have already given the details about the SQL performance tuning with examples. In this article I would like to give the SQL performance technique to use the hints in SQL. In this article I would like to give you the details and example of the most common link which is used to improve the performance of SQL – parallel hint with examples. The parallel hint is used to create the multiple parallel sessions so that the load will be divided properly within sever at the time of execution. If load is dividing parallelly in the sessions then it will definitely improve the performance of the SQL execution.
What you will find in this article?
Syntax :
SELECT /*+ parallel(table_name,degree_of_parallelism) */ column_1, column_2,column..n FROM Table_name;
Example :
SELECT /*+ parallel(employees,8) */ employee_id, Employee_name FROM hr.employees;
The above statement will run the query with 8 degree of parallelism. Here 8 different processes with open to run the select query fast. The each one of the process will take the subset of the data.
If the above employees table has 80000 records this means that each process will process 10000 records parallelly rather than serial execution of 80000 records together.
5. If you want to process the indexes in parallel fashion then you can use the parallel_index hint which has two arguments one is table name and other one is the index name.
Example :
SELECT /*+ parallel_index(emp, employee_id ,8) */ employee_id, name
FROM employees WHERE deptno = 101;
Two arguments used in parallel_index hint: Table name and Index name. If you do not specify parallel number then oracle choose automatic on db settings.
6. If you dont want to use parallel execution if system level or oracle level parallelism is set then you can use NO_PARALLEL or NO_PARALLEL_INDEX hint.
We can use the parallel_enable hint to improve the performance of the user defined functions in oracle SQL. The parallel_enable hint will be used in functions as an optimization hints to run queries in parallelized fashion.
Create or Replace Function F_Square(Num Number)
RETURN Number parallel_enable is
begin
return Num * Num;
End F_Square;
The above function is used to calculate the square of the number uses parallel_enable statement. You can use this function in any query containing the parallel statement.
Select /*+parallel(4)*/ Employee_name,F_Square(sal)/20 as Current_salary from Employees;
The above query as well as function will run parallelly and it will create 4 processes.
Just Remember : The Parallel hints can only be used in Oracle Enterprise Editions.
I hope you like this article on parallel hints. If you like this article or if you have any issues with the same kindly comment in comments section.
In my previous article I have given details about application support engineer day to day…
In my previous articles I have given the roles and responsibilities of L1,L2 and L3…
In my previous articles i have given the hierarchy of production support in real company…
In this article i would like to provide information about production support organization structure or…
In my previous article I have given roles for L1 and L2 support engineer with…
I have started this new series of how to become application support engineer. This article…