Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Poo.

Asked: July 28, 2016 - 8:42 am UTC

Last updated: August 01, 2016 - 3:47 pm UTC

Version: 12c

Viewed 1000+ times

You Asked

I'm using Oracle 12c. I'm calling mutiple procedures from Python in parallel (usually 4-5). I make sure nothing else is running at that time.
All the target and source tables has Parallel 32 Clause .
I'm using hints ENABLE_PARALLEL_DML, PARALLEL in Insert Clause and using PARALLEL hint in select clause.
I have used append clause also, wherever Plan Note suggested.
But still to my surprise , sometimes same procedure query runs with good DOP , sometimes with 1.
Plan Note says, "Object not decorated with Parallel clause".

Below are the DOP parameters setting:

parallel_adaptive_multi_user boolean TRUE
parallel_automatic_tuning boolean FALSE
parallel_degree_level integer 100
parallel_degree_limit string CPU
parallel_degree_policy string ADAPTIVE
parallel_execution_message_size integer 16384
parallel_force_local boolean FALSE
parallel_instance_group string
parallel_io_cap_enabled boolean FALSE
parallel_max_servers integer 752
parallel_min_percent integer 0
parallel_min_servers integer 128
parallel_min_time_threshold string AUTO
parallel_server boolean FALSE
parallel_server_instances integer 1
parallel_servers_target integer 512
parallel_threads_per_cpu integer 2
------------------------------------
CPU parameters:
resource_limit boolean TRUE
resource_manager_cpu_allocation integer 32
resource_manager_plan string DEFAULT_PLAN


I tried running gather stats as below:
exec DBMS_STATS.GATHER_TABLE_STATS (ownname => 'own_name' , tabname => 'tab_name' , estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,granularity => 'GLOBAL AND PARTITION',METHOD_OPT => 'FOR ALL COLUMNS SIZE AUTO', degree => DBMS_STATS.DEFAULT_DEGREE);

Still the problem persists. Please guide me why optimizer choose new DOP under similar conditions.

and Chris said...

You have the parallel_degree_policy parameter set to adaptive. As the docs say this:

This value enables automatic degree of parallelism, statement queuing and in-memory parallel execution, similar to the AUTO value.

https://docs.oracle.com/database/121/REFRN/GUID-BF09265F-8545-40D4-BD29-E58D5F02B0E5.htm#REFRN10310

With auto DOP, the database is free to choose which level of parallelism to run the statement. Note this could be serial!

https://blogs.oracle.com/datawarehousing/entry/auto_dop_and_parallel_statemen

So in your case, the optimizer has decided that the SQL will execute too quickly to be worth using parallel. Hence it's gone for serial (DOP = 1).

If you want to explicitly set the parallel servers, then set parallel_degree_policy to manual.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library