文章不做讲解,仅作日常记录。
- Create pending area for plan, consumer group and directives
begin
dbms_resource_manager.create_pending_area();
end;
/
- Create resource plans
begin
dbms_resource_manager.create_plan(
plan => 'MYDB_PLAN',
comment => 'Resource plan/method for Single level sample');
end;
/
- Create resource consumer groups
begin
dbms_resource_manager.create_consumer_group(
consumer_group => 'OLTP_Group',
comment => 'Resource consumer group/method for online users sessions');
end;
/
--可以配置多个资源组
- Create resource plan directives
begin
dbms_resource_manager.create_plan_directive(
plan => 'mydb_plan',
group_or_subplan => 'OLTP_Group',
comment => 'Online day users sessions at level 1',
cpu_p1 => 80,
parallel_degree_limit_p1 => 0);
dbms_resource_manager.create_plan_directive(
plan => 'mydb_plan',
group_or_subplan => 'BATCH_Group',
comment => 'batch day users sessions at level 1',
cpu_p1 => 10,
parallel_degree_limit_p1 => 10);
dbms_resource_manager.create_plan_directive(
plan => 'mydb_plan',
group_or_subplan => 'ADHOC_Group',
comment => 'ADHOC day users sessions at level 1',
cpu_p1 => 10,
parallel_degree_limit_p1 => 5);
dbms_resource_manager.create_plan_directive(
plan => 'mydb_plan',
group_or_subplan => 'OTHER_GROUPS',
comment => 'OTHER_GROUPS day users sessions at level 1',
cpu_p1 => 0,
parallel_degree_limit_p1 => 0);
end;
/
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (
plan IN VARCHAR2,
group_or_subplan IN VARCHAR2,
comment IN VARCHAR2 DEFAULT NULL,
cpu_p1 IN NUMBER DEFAULT NULL, -- deprecated
cpu_p2 IN NUMBER DEFAULT NULL, -- deprecated
cpu_p3 IN NUMBER DEFAULT NULL, -- deprecated
cpu_p4 IN NUMBER DEFAULT NULL, -- deprecated
cpu_p5 IN NUMBER DEFAULT NULL, -- deprecated
cpu_p6 IN NUMBER DEFAULT NULL, -- deprecated
cpu_p7 IN NUMBER DEFAULT NULL, -- deprecated
cpu_p8 IN NUMBER DEFAULT NULL, -- deprecated
active_sess_pool_p1 IN NUMBER DEFAULT NULL,
queueing_p1 IN NUMBER DEFAULT NULL,
parallel_degree_limit_p1 IN NUMBER DEFAULT NULL,
switch_group IN VARCHAR2 DEFAULT NULL,
switch_time IN NUMBER DEFAULT NULL,
switch_estimate IN BOOLEAN DEFAULT FALSE,
max_est_exec_time IN NUMBER DEFAULT NULL,
undo_pool IN NUMBER DEFAULT NULL,
max_idle_time IN NUMBER DEFAULT NULL,
max_idle_blocker_time IN NUMBER DEFAULT NULL,
switch_time_in_call IN NUMBER DEFAULT NULL, -- deprecated
mgmt_p1 IN NUMBER DEFAULT NULL,
mgmt_p2 IN NUMBER DEFAULT NULL,
mgmt_p3 IN NUMBER DEFAULT NULL,
mgmt_p4 IN NUMBER DEFAULT NULL,
mgmt_p5 IN NUMBER DEFAULT NULL,
mgmt_p6 IN NUMBER DEFAULT NULL,
mgmt_p7 IN NUMBER DEFAULT NULL,
mgmt_p8 IN NUMBER DEFAULT NULL,
switch_io_megabytes IN NUMBER DEFAULT NULL,
switch_io_reqs IN NUMBER DEFAULT NULL,
switch_for_call IN BOOLEAN DEFAULT NULL,
max_utilization_limit IN NUMBER DEFAULT NULL, -- deprecated
parallel_target_percentage IN NUMBER DEFAULT NULL, -- deprecated
parallel_server_limit IN NUMBER DEFAULT NULL,
utilization_limit IN NUMBER DEFAULT NULL,
switch_io_logical IN NUMBER DEFAULT NULL,
switch_elapsed_time IN NUMBER DEFAULT NULL,
shares IN NUMBER DEFAULT NULL,
parallel_stmt_critical IN VARCHAR2 DEFAULT NULL,
session_pga_limit IN NUMBER DEFAULT NULL,
pq_timeout_action IN NUMBER DEFAULT NULL,
parallel_queue_timeout IN NUMBER DEFAULT NULL,);
Parameter | Description |
| Name of the resource plan |
| Name of the consumer group or subplan |
| Comment for the plan directive |
| -- deprecated: use |
| -- deprecated: use |
| -- deprecated: use |
| -- deprecated: use |
| -- deprecated: use |
| -- deprecated: use |
| -- deprecated: use |
| -- deprecated: use |
| Specifies maximum number of sessions that can currently have an active call |
| Specified time (in seconds) after which a call in the inactive session queue (waiting for execution) will time out. Default is |
| Specifies a limit on the degree of parallelism for any operation. Default is |
| Specifies consumer group to switch to, once a switch condition is met. If the group name is |
| Specifies the time on CPU (not elapsed time) that a session can execute before an action is taken. Default is |
| If Default value is |
| Specifies the maximum execution time (in CPU seconds) allowed for a session. If the optimizer estimates that an operation will take longer than |
| Limits the size in kilobytes of the undo records corresponding to uncommitted transactions by this consumer group |
| Indicates the maximum session idle time. Default is |
| Maximum amount of time in seconds that a session can be idle while blocking another session's acquisition of a resource |
| Deprecated. If this parameter is specified, |
| Resource allocation value for level 1 (replaces
|
| Resource allocation value for level 2 (replaces
|
| Resource allocation value for level 3 (replaces
|
| Resource allocation value for level 4 (replaces
|
| Resource allocation value for level 5 (replaces
|
| Resource allocation value for level 6 (replaces
|
| Resource allocation value for level 7 (replaces
|
| Resource allocation value for level 8 (replaces
|
| Specifies the amount of I/O (in MB) that a session can issue before an action is taken. Default is |
| Specifies the number of I/O requests that a session can issue before an action is taken. Default is |
| Specifies that if an action is taken because of the |
| -- deprecated: use |
| -- deprecated: use |
| Specifies the time (in seconds) that a parallel statement may remain in its Consumer Group's parallel statement queue before it is removed and terminated with an error (ORA- 07454). Note: You can use the |
| Specifies the maximum percentage of |
| Resource limit. Currently it includes CPU and I/O for Exadata. For CPU, this limits the CPU utilization for the consumer group. For Exadata I/O, this limits the disk utilization for the consumer group. This does not apply to parallel servers. |
| Number of logical IOs that will trigger the action specified by |
| Elapsed time that will trigger the action specified by |
| Specifies the share of resource allocation for the consumer group. CPU Resource Manager and Exadata I/O Resource Manager are enabled by specifying shares for each consumer group. The |
| If set to If set to Default is |
| Maximum amount of untunable PGA (in MB) that a session in this consumer group can allocate before being terminated. SQL operations that allocate tunable PGA (operations that can opt to use temp space) are not controlled by this limit. |
| Specifies the action to be taken when a parallel statement is removed from the queue due to The values are:
The default action of this parameter is |
- Map sessions to consumer groups, based on the session's login and runtime attributes.
begin
dbms_resource_manager.SET_CONSUMER_GROUP_MAPPING(
DBMS_RESOURCE_MANAGER.ORACLE_USER,'USERNAME','CONSUMER_GROUP');
end;
/
- Validate Pending area for plan, consumer group and directives
begin
dbms_resource_manager.validate_pending_area();
end;
/
- submit pending area for plan, consumer group and directives
begin
dbms_resource_manager.submit_pending_area();
end;
/
select * from dba_rsrc_plan_directives;
RollBack
exec dbms_resource_manager.clear_pending_area();
exec dbms_resource_manager.create_pending_area();
exec dbms_resource_manager.DELETE_PLAN_DIRECTIVE ('plan', 'group_or_subplan');
exec DBMS_RESOURCE_MANAGER.DELETE_PLAN (plan => 'paln_name');
begin
dbms_resource_manager.SET_CONSUMER_GROUP_MAPPING(
DBMS_RESOURCE_MANAGER.ORACLE_USER,'USERNAME','DEFAULT_CONSUMER_GROUP');
end;
/
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('CONSUMER_GROUP');