This document discusses using the resource manager to control parallelism and Auto DOP in the database. It introduces parallelism concepts, Auto DOP, and how the resource manager can be used to limit parallelism through consumer groups, directives, and queuing. Setting up the resource manager divides users into groups, assigns parallel limits, and prevents performance degradation by queuing queries rather than allowing parallelism to downgrade. The resource manager provides finer control over Auto DOP and makes parallelism usage and throughput more predictable.
2. Introduction
Rick van Ek
Oracle Senior DBA
Involved with Oracle since 1992
Independent since 1996
https://nl.linkedin.com/in/rickvek
Married, two children
3. Agenda
Parallelism
Very short introduction.
Auto DOP (Degree Of Parallel)
Auto Dop and Resource manager
5. Parallelism
Database level
Alter system set
Choose with Care
Session level (our preferred method)
Alter session ;
ALTER SESSION SET parallel_degree_policy = limited;
Use a logon trigger.
Object level
Alter table . parallel( not recommended)
Query level, use hint.
Needs a change in your application, you not always can or want that.
6. Parallelism
Max parallel processes on > 11.2.0.2 from Oracle Documentation.
"parallel_max_servers = PARALLEL_THREADS_PER_CPU *
CPU_COUNT * concurrent_parallel_users * 5
In the formula, the value assigned to concurrent_parallel_users running at
the default degree of parallelism on an instance is dependent on the
memory management setting. If automatic memory management is
disabled (manual mode), then the value of concurrent_parallel_users is 1.
If PGA automatic memory management is enabled, then the value of
concurrent_parallel_users is 2.
If global memory management or SGA memory target is used in addition
to PGA automatic memory management, then the value of
concurrent_parallel_users is 4.
The value is capped by processes -15."
7. Parallelism
Memory usage;
Is hard to tell upfront. But it can be measured.
Look into v$px_buffer_advice.
Monitor you usage.
SELECT POOL, NAME, SUM(BYTES) FROM
V$SGASTAT WHERE POOL LIKE '%pool%'
GROUP BY ROLLUP (POOL, NAME);
Do not forget to measure your PGA usage.
9. Parallelism
Query Coordinator QC foreground process
for driving sessions. Receives data from
query slaves.
Slaves
Producer slaves- get their work from QC, returns
data in queues. For QC or Consumer Slaves.
Consumer slaves (only generated when needed).
Reads from queue and returns to the QC
10. Parallelism
Skew Of Data Distribution Across Parallel
Slaves.
Some slaves have more work to do then others.
Observed with partitions.
Use sql monitor, easier to find.
http://allthingsoracle.com/parallel-execution-skew-demonstrating-skew/
12. Parallelism
Pros
Simple setup
Resource usage is limited, easy overview
Cons
Needs maintenance
Downgrade when resources are exhausted
Downgrades makes run time unpredictable.
All queries gets same parallelism, even if they don't need it.
13. Auto DOP
"The AutoDOP is not a feature to use more
parallelism. It is a feature that restricts the
parallel execution using a balance of cost-
benefit. so it is expected that with AutoDOP
not all queries will run in parallel and the ones
that do run in parallel may not run with full
parallelism, as this is the technical
specifications of the feature."
Quote from Oracle Documentation.
14. Auto DOP
Is dependend on :
IO Calibration.
System statistics.
Object statistics.
Resource Manager default plan active.
15. Auto DOP
Check configuration before use.
MOS script pxhcdr.sql
Use output as input for your setup.
16. Auto DOP
IO Calibration:
Runs for 15 minutes on a database
Database must be in restricted mode
Parameters can be added later manually
For SAN, take large number of disks (> 200)
There are different opinions about the usage of
these parameters.
Exadata : use metric_iorm.pl (Doc id 1337265.1)
17. Auto DOP
System Statistics
Workload
No-Workload
Make up your mind.
18. Auto DOP
Object statistics:
Make sure they are up to date
Determine strategy
All including histograms
All excluding histograms, only histograms were
needed.
Tip large database with lots of partitions :
Use concurrent=true parameter, also on > 11.2.0.3 see
documentation on 12C.
19. Auto DOP
Parameters:
parallel_degree_policy = auto
Can be set on database level
Can be set on session level*
parallel_force_local= true/false
Can profit from cluster, more resources.
parallel_degree_limit= CPU
parallel_min_time_threshold
Default = 10 sec. , if elapse time is > 10 sec. then go parallel.
* We use this a lot for testing
21. Auto DOP
Pros
Fluctuations in number DOP.
Some efficiency in usage of resources.
Cons
Resources can still be exhausted.
Downgrades still possible
Some queries can take to much DOP
Seen sessions which take up 64 parallel processes.
Chaos can happen as they are out of control.
22. Monitoring
Use sql-monitor from EM.
There are views to use.
Keep observing behavior, now it is (looking)
under control. But it can be chaos with the
next change.
23. Conclusion
This setup is not suitable for a production
enviroment with lots of changes.
More companies use DevOps, so more
changes.
If you need it for a batch, use it on session
level for the batch user.
24. Next Step
Handle the cons, get in control.
The resource manager gives you the tools
to get in control.
25. Resource Manager
Setup Resource Manager
User set limit for Auto DOP.
Activates queuing for parallel query.
Can stop/abort long runners.
Basically getting into control.
26. Resource Manager
Setting up the resource manager
Create resource plan
Create consumer group(s)
Add the consumer group(s) to resource plan.
Add other group to resource plan (default)
Create directives for consumer group(s)
Assign users to consumer group(s)
Default consumer group.
Logon trigger.
Activate resource plan
Example on MOS Doc id 1359043.1
27. Resource Manager
RESOURCE PLANRESOURCE PLAN
Consumer Group
Batch users
Consumer Group
Batch users
Consumer Group
Analytics
Consumer Group
Analytics
Consumer Group
Named Users
Consumer Group
Named Users
Consumer Group
OTHER
Consumer Group
OTHER
DirectiveDirective
DirectiveDirective
DirectiveDirective
DirectiveDirective
DirectiveDirective
DirectiveDirective
DirectiveDirective DirectiveDirective
DirectiveDirective DirectiveDirective
28. Resource Manager
Resource Plan
Make a new one save the default for fall back
Do not make it more complicated then needed.
Divide the amount of resources between your
consumer groups and other group.
30. Resource Manager
Consumer group.
This is what you assign to your users.
Batch job.
Tactical queries.
Other application users.
Capabilities of group is determine by directives.
dba_rsrc_consumer_groups
32. Resource Manager
Directives
dbms_resource_manager.create_plan_directive
mgmt_pX Resource allocation value for level X
(replaces cpu_pX):
EMPHASIS - specifies the resource percentage at the Xst
level
parallel_degree_limit_p1
Specifies a limit on the degree of parallelism for any
operation.
Default is NULL, which means unlimited.
33. Resource Manager
The limit is very important, it set the max.
level of DOP to be used by Auto DOP.
Example :
Normal parallel we used 8
With this setup we used 14,
Tested with 8, 10, 12, 14, 16, 18. But 14 seemed
to be optimal.
So gradually increase this value.
34. Resource Manager
Directives
dbms_resource_manager.create_plan_directive
parallel_target_percentage
Specifies the maximum percentage of the target number of
parallel servers in an Oracle RAC environment that a
consumer group can use. Any additional parallel statements
that are launched from this consumer group will be queued.
The default is NULL, which means that the limit is 100% of
the target number. Valid values for queuing are in the range
of 0 to 100 (%). For updates to the plan directive, the value
of -1 will reset the value to NULL.
35. Resource Manager
Queuing
This is the most important part. It prevents the
database from downgrading the DOP.
Better to wait for 5 or 10 minutes then running a
query which will take 8 hours. Instead of 30
minutes.
Makes your throughput better predictable.
36. Resource Manager
Directives
dbms_resource_manager.create_plan_directive
parallel_queue_timeout
Specifies the time (in seconds) that a query may remain in
its Consumer Group's parallel statement queue before it is
removed and terminated with an error (ORA- 07454).
37. Resource Manager
Directives
dbms_resource_manager.create_plan_directive
max_est_exec_time
Specifies the maximum execution time (in CPU seconds)
allowed for a session. If the optimizer estimates that an
operation will take longer than MAX_EST_EXEC_TIME, the
operation is not started and ORA-07455 is issued. If the
optimizer does not provide an estimate, this directive has no
effect. Default is NULL, which means unlimited.
40. Resource Manager
Assign user to consumer group.
We placed every user in its appointed
consumer group.
With login they are assigned to their initial
Consumer Group.
41. Resource Manager
for people in
(select username usr
from dba_users
where username like 'OWNER%'
and username not like '%PC1'
)
loop
dbms_output.put_line('Processing user : '|| people.usr ) ;
dbms_resource_manager_privs.grant_switch_consumer_group( grantee_name => people.usr
, consumer_group => '&&group2'
, grant_option => FALSE ) ;
dbms_resource_manager.set_initial_consumer_group( user => people.usr
, consumer_group => '&&group2' ) ;
end loop ;
42. Resource Manager
Modify Maintenance plan
Make a new level add consumers group
If the user runs queries while maintenance plan
is active. Then they are out of control.
43. Resource Manager
What to monitor
Limits on consumer group.
Amount of queuing
Skew
Px buffer
MOS Doc id 1359043.1 has some nice queries to
start with.
EM SQL monitor also give some insights.
44. Resource Manager
Remarks
11.2.0.2 < your version >11.2.0.4 => check
your patches MOS Doc id 1340180.1
45. What have we achieved?
Finer tuning of Auto DOP.
DOP only used when needed.
Limiting on DOP while running Auto DOP.
Queuing on PQ, preventing downgrades.
Group users in Consumer Groups, different
levels of DOP limit/resources.
All is arranged inside the database.
46. Finally the end.
There is more to explore.
If you know the involved parts, then the
search is easier.
Plenty to test.