-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpsft_resource_plan_simple.sql
278 lines (261 loc) · 15.2 KB
/
psft_resource_plan_simple.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
REM psft_resource_plan_simple.sql
REM https://blog.psftdba.com/2024/03/psftplan-sample-oracle-database.html
set trimspool on pages 999 lines 180 termout on serveroutput on
clear screen
spool psft_resource_plan_simple.lst
--------------------------------------------------------------------------------
set echo on
exec DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
--exec DBMS_RESOURCE_MANAGER.DELETE_PLAN('PSFT_PLAN_OTHERS');
exec DBMS_RESOURCE_MANAGER.DELETE_PLAN_CASCADE('PSFT_PLAN');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('HIGH_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('PSFT_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('PSFT_HIGHPQ_GROUP');
--exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('SUML_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('NVISION_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('PSBATCH_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('PSQUERY_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('PSQUERY_ONLINE_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('PSQUERY_BATCH_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('NVSRUN_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('LOW_GROUP');
exec DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP('LOW_LIMITED_GROUP');
begin
for i in (
SELECT DISTINCT m.*
FROM DBA_RSRC_PLAN_DIRECTIVES d, DBA_RSRC_GROUP_MAPPINGS m
WHERE d.plan like 'PSFT_PLAN%'
and d.type = 'CONSUMER_GROUP'
and m.consumer_group = d.group_or_subplan
) loop
dbms_output.put_line('Deleting mapping attribute='||i.attribute||', value='||i.value);
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => i.attribute, value => i.value, consumer_group => NULL);
END LOOP;
end;
/
--------------------------------------------------------------------------------
--Create a plan to manage these consumer groups
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_PLAN('PSFT_PLAN', 'Sample Plan for PeopleSoft');
END;
/
/* Create consumer groups.
* By default, users start in OTHER_GROUPS, which is automatically
* created for every database.
* NB: This will error if the groups exist in another plan - this error can be ignore
*/
exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('PSFT_GROUP', 'General PeopleSoft group');
--exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('PSFT_HIGHPQ_GROUP', 'PeopleSoft High Query Parallelism group');
--exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('HIGH_GROUP', 'High Priority Group.');
--exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('SUML_GROUP', 'Summary Ledger Processing.');
exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('NVISION_GROUP', 'nVision Reports.');
exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('PSBATCH_GROUP', 'General Batch Processing.');
exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('PSQUERY_ONLINE_GROUP', 'PeopleSoft PS/Query group');
exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('PSQUERY_BATCH_GROUP', 'PeopleSoft PS/Query group');
exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('NVSRUN_GROUP', 'Single nVision Report group');
exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('LOW_GROUP', 'Low Priority Group.');
exec DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('LOW_LIMITED_GROUP', 'Low Priority Limited Group.');
--------------------------------------------------------------------------------
--create directives within plan
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'SYS_GROUP', 'Directive for sys activity'
,mgmt_p1 => 100);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'PSFT_GROUP', 'General PeopleSoft group'
-- ,parallel_degree_limit_p1=>n
-- ,mgmt_p2 => 79
,mgmt_p2 => 100
);
--DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
-- 'PSFT_PLAN', 'PSFT_HIGHPQ_GROUP', 'PeopleSoft High Query Parallelism group'
-- ,parallel_degree_limit_p1=>n
-- ,mgmt_p2 => 20);
--DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
-- 'PSFT_PLAN', 'HIGH_GROUP', 'High priority group'
-- ,parallel_degree_limit_p1=>n
-- ,mgmt_p2 => 1);
--DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
-- 'PSFT_PLAN', 'SUML_GROUP', 'Summary Ledger Processing.'
-- ,mgmt_p3 => 100
-- ,parallel_degree_limit_p1=>n
--);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'PSBATCH_GROUP', 'nVision Reports.'
,mgmt_p4 => 100
-- ,parallel_degree_limit_p1=>n
);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'NVISION_GROUP', 'nVision Reports.'
,mgmt_p5 => 100
-- ,parallel_degree_limit_p1=>n
);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'PSQUERY_ONLINE_GROUP'
,mgmt_p6 => 90
-- ,parallel_degree_limit_p1=>2
);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'PSQUERY_BATCH_GROUP'
,mgmt_p6 => 1
,switch_group => 'CANCEL_SQL'
,switch_time => 14400
,switch_estimate => TRUE
,switch_for_call => TRUE
-- ,parallel_degree_limit_p1=>1
-- ,parallel_queue_timeout=>900
-- ,pq_timeout_action=>'RUN'
);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE( /*added 2.11.2023*/
'PSFT_PLAN', 'NVSRUN_GROUP'
,mgmt_p6 => 9
-- ,parallel_degree_limit_p1=>n
);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'LOW_GROUP'
,mgmt_p8 => 1);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'LOW_LIMITED_GROUP'
,mgmt_p8 => 1
,switch_group => 'CANCEL_SQL'
,switch_time => 7200
,switch_elapsed_time => 7200
,switch_estimate => TRUE
,switch_for_call => TRUE
-- ,parallel_degree_limit_p1=>4
);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'OTHER_GROUPS'
,mgmt_p8 => 1
-- ,parallel_degree_limit_p1=>4
);
END;
/
--------------------------------------------------------------------------------
--create automatic mapping rules - users - by default, anything connected to SYSADM goes into the PSFT_GROUP
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.ORACLE_USER, value => 'PS' , consumer_group => 'PSFT_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.ORACLE_USER, value => 'SYSADM', consumer_group => 'PSFT_GROUP');
END;
/
--------------------------------------------------------------------------------
--create automatic mapping rules - programs that go into a group other than the PSFT_GROUP
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSAPPSRV%' , consumer_group => 'PSFT_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSQRYSRV%' , consumer_group => 'PSQUERY_ONLINE_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSNVSSRV%' , consumer_group => 'NVSRUN_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'psae%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSAESRV%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSDSTSRV%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSMSTPRC%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSPRCSRV%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSRUNRMT%' , consumer_group => 'PSFT_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSRUN@%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSSQR%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'pssqr%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'sqr%' , consumer_group => 'PSBATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'SQL Developer%', consumer_group => 'LOW_LIMITED_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'sqlplus%' , consumer_group => 'LOW_LIMITED_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'Toad%' , consumer_group => 'LOW_LIMITED_GROUP');
END;
/
--------------------------------------------------------------------------------
--create automatic mapping rules - by module/action
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME , value => 'PSAE.PSQUERY.%', consumer_group => 'PSQUERY_BATCH_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM , value => 'PSQRYSRV%' , consumer_group => 'PSQUERY_ONLINE_GROUP');
--DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME , value => 'psqrysrv%' , consumer_group => 'PSQUERY_ONLINE_GROUP');
--PIA component that runs queries on-line
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME_ACTION, value => 'QUERY_MANAGER.QUERY_VIEWER', consumer_group => 'PSQUERY_ONLINE_GROUP');
END;
/
--------------------------------------------------------------------------------
BEGIN
--DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME, value => 'GLPOCONS' , consumer_group => 'PSFT_HIGHPQ_GROUP');
--DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME, value => 'PSAE.GL_JEDIT2.%', consumer_group => 'PSFT_HIGHPQ_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME, value => 'RPTBOOK' , consumer_group => 'NVISION_GROUP');
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME, value => 'NVSRUN' , consumer_group => 'NVSRUN_GROUP');
--DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME, value => 'PSAE.GL_SUML.%' , consumer_group => 'SUML_GROUP');
END;
/
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME, value => 'KTSJ' , consumer_group => 'SYS_GROUP');
--dbms_resource_manager.set_consumer_group_mapping (attribute => 'ORACLE_FUNCTION' , value => 'INMEMORY', consumer_group => 'SUML_GROUP');
END;
/
--------------------------------------------------------------------------------
--see Bug 34286049 - stress:fa:huge increase in the number of aq$_plsql_ntfn jobs in 19.15 leading to performance issues (Doc ID 34286049.8)
--------------------------------------------------------------------------------
--BEGIN
-- DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (
-- attribute => DBMS_RESOURCE_MANAGER.MODULE_NAME_ACTION,
-- value => 'DBMS_SCHEDULER.AQ$_PLSQL_NTFN%',
-- consumer_group => 'LOW_GROUP');
--END;
--/
--------------------------------------------------------------------------------
--added 21.10.2023 - long running purge of AQ tables consumes CPU - might not be able to reassign this process
--see Bug 34774667 - [AQ] Global-buffer-overflow in pga at kwqalockqtwithinfo with ORA-00700 During PURGE_QUEUE_TABLE. (Doc ID 34774667.8)
--------------------------------------------------------------------------------
--BEGIN DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (
-- attribute => DBMS_RESOURCE_MANAGER.CLIENT_PROGRAM,
-- value => 'oracle@%(SVCB)',
-- consumer_group => 'LOW_GROUP');
--END;
--/
--------------------------------------------------------------------------------
-- reprioritise mapping attributes
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping_pri (
explicit => 1,
module_name_action => 2,
module_name => 3,
client_program => 4,
oracle_user => 5,
--this resource plan does not use the following attributes
service_name => 6,
client_os_user => 7,
client_machine => 8,
service_module => 9,
service_module_action => 10);
END;
/
/--------------------------------------------------------------------------------
exec DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
exec DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
--------------------------------------------------------------------------------
-- Explicitly grant RSRC system priv to SYSADM not via role for trigger
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SYSTEM_PRIVILEGE (
grantee_name => 'SYSADM',
privilege_name => 'ADMINISTER_RESOURCE_MANAGER',
admin_option => FALSE);
END;
/
--------------------------------------------------------------------------------
-- Allow PeopleSoft owner id to run in these consumer groups
--------------------------------------------------------------------------------
BEGIN
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'SYS_GROUP' , FALSE);
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'PSFT_GROUP' , FALSE);
--DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'PSFT_HIGHPQ_GROUP' , FALSE);
--DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'SUML_GROUP' , FALSE);
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'NVISION_GROUP' , FALSE);
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'PSBATCH_GROUP' , FALSE);
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'PSQUERY_BATCH_GROUP' , FALSE);
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'PSQUERY_ONLINE_GROUP', FALSE);
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'NVSRUN_GROUP' , FALSE);
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'LOW_GROUP' , FALSE);
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP('SYSADM', 'LOW_LIMITED_GROUP' , FALSE);
END;
/
--------------------------------------------------------------------------------
spool off