Thursday, October 26, 2017

Table or index Fragmentation



TABLE FRAGMENTATION:

--Query to find out fragementation
select owner,table_name,round((blocks*16),2)||'kb' "Fragmented size", round((num_rows*avg_row_len/1024),2)||'kb' "Actual size", round((blocks*16),2)-round((num_rows*avg_row_len/1024),2)||'kb',
((round((blocks*16),2)-round((num_rows*avg_row_len/1024),2))/round((blocks*16),2))*100 -10 "reclaimable space % " from dba_tables where table_name ='DEPDMDSTATIC' AND OWNER LIKE 'SCPOMGR';

declare
   l_fs1_bytes number;
   l_fs2_bytes number;
   l_fs3_bytes number;
   l_fs4_bytes number;
   l_fs1_blocks number;
   l_fs2_blocks number;
   l_fs3_blocks number;
   l_fs4_blocks number;
   l_full_bytes number;
   l_full_blocks number;
   l_unformatted_bytes number;
   l_unformatted_blocks number;
  begin
   dbms_space.space_usage(
      segment_owner      => user,
      segment_name       => 'PLANORDER',
      segment_type       => 'TABLE',
      fs1_bytes          => l_fs1_bytes,
      fs1_blocks         => l_fs1_blocks,
      fs2_bytes          => l_fs2_bytes,
      fs2_blocks         => l_fs2_blocks,
      fs3_bytes          => l_fs3_bytes,
      fs3_blocks         => l_fs3_blocks,
      fs4_bytes          => l_fs4_bytes,
      fs4_blocks         => l_fs4_blocks,
      full_bytes         => l_full_bytes,
      full_blocks        => l_full_blocks,
      unformatted_blocks => l_unformatted_blocks,
      unformatted_bytes  => l_unformatted_bytes
    --  partition_name     => 'P_-106'
   );
   dbms_output.put_line(' FS1 Blocks = '||l_fs1_blocks||' Bytes = '||l_fs1_bytes);
   dbms_output.put_line(' FS2 Blocks = '||l_fs2_blocks||' Bytes = '||l_fs2_bytes);
   dbms_output.put_line(' FS3 Blocks = '||l_fs3_blocks||' Bytes = '||l_fs3_bytes);
   dbms_output.put_line(' FS4 Blocks = '||l_fs4_blocks||' Bytes = '||l_fs4_bytes);
   dbms_output.put_line('Full Blocks = '||l_full_blocks||' Bytes = '||l_full_bytes);
end;
/


INDEX FRAGMENTATION:

We need to analyze the index fragmentation post migration
Please use the below script to do so. After completion of the PLSQL block check the dl_lf_rows and based on the high values we can select candidates for doing rebuild.

CREATE TABLE index_frag
(
   exec_date     DATE,
   index_name    VARCHAR2 (30),
   blocks        NUMBER,
   lf_blks       NUMBER,
   del_lf_rows   NUMBER
);



DECLARE
BEGIN
   FOR c_rec IN (SELECT index_name
                   FROM user_indexes
                  WHERE table_name NOT IN (SELECT TABLE_NAME
                                             FROM user_tables
                                            WHERE IOT_TYPE IS NOT NULL))
   LOOP
      BEGIN
         EXECUTE IMMEDIATE
            'ANALYZE  INDEX ' || c_rec.index_name || 'VALIDATE  STRUCTURE';

         INSERT INTO index_frag
            SELECT SYSDATE,
                   c_rec.index_name,
                   blocks,
                   lf_blks,
                   del_lf_rows
              FROM index_stats;
          COMMIT;
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line ('Issue with Index : ' || c_rec.index_name);
            CONTINUE;
      END;
   END LOOP;
END;
/

set echo off
set termout off
set verify off
set trimspool on
set feedback off
set heading off
set lines 300
set pages 0
set serverout on
spool analyze_User1_indexes.tmp

select 'exec DBMS_STATS.UNLOCK_TABLE_STATS ('''|| user ||''','''|| table_name ||''');' from user_tables order by table_name asc;

begin
for x in ( select index_name from user_indexes where index_type = 'NORMAL')
loop
dbms_output.put_line('ANALYZE INDEX ' || x.index_name || ' COMPUTE STATISTICS;');
dbms_output.put_line('ANALYZE INDEX ' || x.index_name || ' VALIDATE STRUCTURE;');
dbms_output.put_line('select name, height, lf_rows, del_lf_rows, round((del_lf_rows/lf_rows)*100,2) as ratio from index_stats where (lf_rows > 100 and del_lf_rows
> 0)
and (height > 3 or ((del_lf_rows/lf_rows)*100) > 20);');
end loop;
end;
/

select 'exec DBMS_STATS.LOCK_TABLE_STATS ('''|| user ||''','''|| table_name ||''');' from user_tables order by table_name asc;

spool off
column name format a40
spool FPATH/analyze_User1_index_report.txt
PROMPT NAME | HEIGHT | LF_ROWS | DEL_LF_ROWS | RATIO (del_lf_rows/lf_rows) %
@@$FPATH/analyze_User1_indexes.tmp
spool off

create or replace
procedure show_space
( p_segname in varchar2,
p_owner in varchar2 default user,
p_type in varchar2 default 'TABLE',
p_partition in varchar2 default NULL )
authid current_user
as
l_free_blks number;

l_total_blocks number;
l_total_bytes number;
l_unused_blocks number;
l_unused_bytes number;
l_LastUsedExtFileId number;
l_LastUsedExtBlockId number;
l_LAST_USED_BLOCK number;
procedure p( p_label in varchar2, p_num in number )
is
begin
dbms_output.put_line( rpad(p_label,40,'.') ||
p_num );
end;
begin
for x in ( select tablespace_name
from dba_tablespaces
where tablespace_name = ( select tablespace_name
from dba_segments
where segment_type = p_type
and segment_name = p_segname
and SEGMENT_SPACE_MANAGEMENT <> 'AUTO' )
)
loop
dbms_space.free_blocks
( segment_owner => p_owner,
segment_name => p_segname,
segment_type => p_type,
partition_name => p_partition,
freelist_group_id => 0,
free_blks => l_free_blks );
end loop;

dbms_space.unused_space
( segment_owner => p_owner,
segment_name => p_segname,
segment_type => p_type,
partition_name => p_partition,
total_blocks => l_total_blocks,
total_bytes => l_total_bytes,
unused_blocks => l_unused_blocks,
unused_bytes => l_unused_bytes,
LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
LAST_USED_BLOCK => l_LAST_USED_BLOCK );

p( 'Free Blocks', l_free_blks );
p( 'Total Blocks', l_total_blocks );
p( 'Total Bytes', l_total_bytes );
p( 'Total MBytes', trunc(l_total_bytes/1024/1024) );
p( 'Unused Blocks', l_unused_blocks );
p( 'Unused Bytes', l_unused_bytes );
p( 'Last Used Ext FileId', l_LastUsedExtFileId );
p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
p( 'Last Used Block', l_LAST_USED_BLOCK );
end;
/



--
-- File name: indexes_2b_shrunk.sql
--
-- Purpose: List of candidate indexes to be shrunk (rebuild online)
--
-- Author: Carlos Sierra
--
-- Version: 2017/07/12
--
-- Usage: Execute on PDB
--
-- Example: @indexes_2b_shrunk.sql
--
-- Notes: Execute connected into a PDB.
-- Consider then:
-- ALTER INDEX [schema.]index REBUILD ONLINE;
--
---------------------------------------------------------------------------------------
 
-- select only those indexes with an estimated space saving percent greater than 25%
VAR savings_percent NUMBER;
EXEC :savings_percent := 25;
-- select only indexes with current size (as per cbo stats) greater then 1MB
VAR minimum_size_mb NUMBER;
EXEC :minimum_size_mb := 1;
 
SET SERVEROUT ON ECHO OFF FEED OFF VER OFF TAB OFF LINES 300;
 
COL report_date NEW_V report_date;
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD"T"HH24:MI:SS') report_date FROM DUAL;
SPO /tmp/indexes_2b_shrunk_&&report_date..txt;
 
DECLARE
l_used_bytes NUMBER;
l_alloc_bytes NUMBER;
l_percent NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('PDB: '||SYS_CONTEXT('USERENV', 'CON_NAME'));
DBMS_OUTPUT.PUT_LINE('---');
DBMS_OUTPUT.PUT_LINE(
RPAD('OWNER.INDEX_NAME', 35)||' '||
LPAD('SAVING %', 10)||' '||
LPAD('CURRENT SIZE', 20)||' '||
LPAD('ESTIMATED SIZE', 20));
DBMS_OUTPUT.PUT_LINE(
RPAD('-', 35, '-')||' '||
LPAD('-', 10, '-')||' '||
LPAD('-', 20, '-')||' '||
LPAD('-', 20, '-'));
FOR i IN (SELECT x.owner, x.index_name, SUM(s.leaf_blocks) * TO_NUMBER(p.value) index_size,
REPLACE(DBMS_METADATA.GET_DDL('INDEX',x.index_name,x.owner),CHR(10),CHR(32)) ddl
FROM dba_ind_statistics s, dba_indexes x, dba_users u, v$parameter p
WHERE u.oracle_maintained = 'N'
AND x.owner = u.username
AND x.tablespace_name NOT IN ('SYSTEM','SYSAUX')
AND x.index_type LIKE '%NORMAL%'
AND x.table_type = 'TABLE'
AND x.status = 'VALID'
AND x.temporary = 'N'
AND x.dropped = 'NO'
AND x.visibility = 'VISIBLE'
AND x.segment_created = 'YES'
AND x.orphaned_entries = 'NO'
AND p.name = 'db_block_size'
AND s.owner = x.owner
AND s.index_name = x.index_name
GROUP BY
x.owner, x.index_name, p.value
HAVING
SUM(s.leaf_blocks) * TO_NUMBER(p.value) > :minimum_size_mb * POWER(2,20)
ORDER BY
index_size DESC)
LOOP
DBMS_SPACE.CREATE_INDEX_COST(i.ddl,l_used_bytes,l_alloc_bytes);
IF i.index_size * (100 - :savings_percent) / 100 > l_alloc_bytes THEN
l_percent := 100 * (i.index_size - l_alloc_bytes) / i.index_size;
DBMS_OUTPUT.PUT_LINE(
RPAD(i.owner||'.'||i.index_name, 35)||' '||
LPAD(TO_CHAR(ROUND(l_percent, 1), '990.0')||' % ', 10)||' '||
LPAD(TO_CHAR(ROUND(i.index_size / POWER(2,20), 1), '999,999,990.0')||' MB', 20)||' '||
LPAD(TO_CHAR(ROUND(l_alloc_bytes / POWER(2,20), 1), '999,999,990.0')||' MB', 20));
END IF;
END LOOP;
END;
/
 
SPO OFF;

How to create sql profile

Note that it needs Enterprise edition with Diagnostic and Tuning pack 

-- START
-- This script creates a SQL Profile for a statement from a hint
-- Run as SYSTEM
-- Step 1 - Remove and prior SQL PROFILEs for target statement
SELECT NAME,
CATEGORY,
SIGNATURE,
CREATED,
LAST_MODIFIED,
DESCRIPTION,
TYPE,
STATUS,
FORCE_MATCHING,
TASK_ID,
TASK_EXEC_NAME,
TASK_OBJ_ID,
TASK_FND_ID,
TASK_REC_ID,
TO_CHAR (SUBSTR (dsp.sql_text, 1, 4000))
FROM dba_sql_profiles dsp;
BEGIN
DBMS_SQLTUNE.DROP_SQL_PROFILE (name => 'PROFILE_cr11zbr8nbr2v');
END;
/
-- Step 2 Clear shared pool
ALTER SYSTEM FLUSH SHARED_POOL;
-- Step 3 - Execute the original statement
-- This will need to run from another session as : SCPOMGR
Select ds.dmdunit, ds.dmdGroup, ds.dfuloc, ds.model, ds.Item, ds.skuLoc, ds.eff, ds.disc, ds.fcstType, ds.supersedesw, ds.convfactor, ds.allocfactor from DFUTOSKU ds, processdfu pd, (select item, skuloc from DFUTOSKU ds1, processdfu pd1 where pd1.stage = 0 AND pd1.processID = :1 and ds1.dmdunit = pd1.dmdunit AND ds1.dmdgroup = pd1.dmdgroup AND ds1.dfuloc = pd1.Loc AND ds1.model = pd1.model group by(item, skuloc) having count(*)=1) s where ds.dmdunit = pd.dmdunit AND ds.dmdgroup = pd.dmdgroup AND ds.dfuloc = pd.Loc AND ds.model = pd.model AND pd.stage = 0 AND pd.processID = :2 AND pd.BatchNum = :3 AND ds.item = s.item AND ds.skuloc = s.skuloc; INTERNAL AND CONFIDENTIAL 2015_SHOPRITE_SCPO80_PERFORMANCEINVESTIGATION_20151126 (V1.6) 30

-- Step 4 - Find SQL ID and CHILD NUMBER for the original statement
SELECT sql_id,
child_number,
sql_text,
sql_fulltext
FROM v$sql
WHERE sql_id LIKE '%'
AND UPPER(sql_text) LIKE 'SELECT%DFU%'
AND sql_text NOT LIKE 'SELECT sql_id%' -- this statement
;
-- Step 5 - Create a SQL PROFILE for hinted statement
DECLARE
in_sql_id V$SQL.SQL_ID%TYPE := 'cr11zbr8nbr2v';
in_child_number V$SQL.CHILD_NUMBER%TYPE := '0';
in_profile_hints SYS.sqlprof_attr
:= sqlprof_attr (
'USE_HASH_AGGREGATION(@"SEL$F5BB74E1")',
'USE_HASH(@"SEL$F5BB74E1" "PD1"@"SEL$2")',
'USE_NL(@"SEL$F5BB74E1" "DS1"@"SEL$2")',
'USE_NL(@"SEL$F5BB74E1" "DS"@"SEL$1")'
);
-- use force_match => true to use CURSOR_SHARING=SIMILAR behaviour, i.e. match even with differing literals
in_force_match BOOLEAN := TRUE;
var_sql_text CLOB;
var_profile_name DBA_SQL_PROFILES.NAME%TYPE;
CURSOR cur_profiles
IS
SELECT dsp.NAME, TO_CHAR (SUBSTR (dsp.sql_text, 1, 4000))
FROM dba_sql_profiles dsp
WHERE dsp.name = var_profile_name;
BEGIN
var_profile_name := 'PROFILE_' || in_sql_id;
FOR prof IN cur_profiles
LOOP
DBMS_SQLTUNE.DROP_SQL_PROFILE (name => prof.name);
END LOOP;
SELECT sql_fulltext
INTO var_sql_text
FROM v$sql
WHERE sql_id = in_sql_id AND child_number = in_child_number;
DBMS_OUTPUT.Put_line (
'_________________________________________________________________');
DBMS_OUTPUT.Put_line ('Creating Profile');
DBMS_OUTPUT.Put_line (' SQL ID :' || in_sql_id);
DBMS_OUTPUT.Put_line (' Child Number :' || in_child_number);
DBMS_OUTPUT.Put_line (' SQL TEXT :' || var_sql_text);
DBMS_OUTPUT.Put_line (' Profile Name :' || var_profile_name);
DBMS_SQLTUNE.import_sql_profile (sql_text => var_sql_text,
profile => in_profile_hints, INTERNAL AND CONFIDENTIAL 2015_SHOPRITE_SCPO80_PERFORMANCEINVESTIGATION_20151126 (V1.6) 31

category => 'DEFAULT',
name => var_profile_name -- use force_match => true
-- to use CURSOR_SHARING=SIMILAR
-- behaviour, i.e. match even with
-- differing literals
,
force_match => in_force_match);
END;
/
-- END
-- List PROFILES
SELECT NAME,
CATEGORY,
SIGNATURE,
CREATED,
LAST_MODIFIED,
DESCRIPTION,
TYPE,
STATUS,
FORCE_MATCHING,
TASK_ID,
TASK_EXEC_NAME,
TASK_OBJ_ID,
TASK_FND_ID,
TASK_REC_ID,
TO_CHAR (SUBSTR (dsp.sql_text, 1, 4000))

FROM dba_sql_profiles dsp;

Create parallel processing in standard oracle edition

DECLARE
   l_task       VARCHAR2 (30) := 'task_del_dfupricepatric';
   l_sql_stmt   VARCHAR2 (32767);
   l_try        NUMBER;
   l_status     NUMBER;
BEGIN
   BEGIN
      DBMS_PARALLEL_EXECUTE.drop_task (l_task);
   EXCEPTION
      WHEN OTHERS
      THEN
         NULL;
   END;

   DBMS_PARALLEL_EXECUTE.create_task (task_name => l_task);

   DBMS_PARALLEL_EXECUTE.create_chunks_by_rowid (
      task_name     => l_task,
      table_owner   => 'SCOTT',
      table_name    => 'DFUPRICERIC',
      by_row        => FALSE,
      chunk_size    => 10000);
   l_sql_stmt :=
      'DELETE FROM scpomgr.dfupricepetric WHERE startdate < sysdate -671
                 and rowid BETWEEN :start_id AND :end_id';

   DBMS_PARALLEL_EXECUTE.run_task (task_name        => l_task,
                                   sql_stmt         => l_sql_stmt,
                                   language_flag    => DBMS_SQL.NATIVE,
                                   parallel_level   => 100);

   COMMIT;
   l_try := 0;
   l_status := DBMS_PARALLEL_EXECUTE.task_status (l_task);

   WHILE (l_try < 2 AND l_status != DBMS_PARALLEL_EXECUTE.FINISHED)
   LOOP
      l_try := l_try + 1;
      DBMS_PARALLEL_EXECUTE.resume_task (l_task);
      l_status := DBMS_PARALLEL_EXECUTE.task_status (l_task);
   END LOOP;
END;
/

Kill orphaned DB connections

BEGIN
   FOR i
      IN (SELECT sid, serial# serial
            FROM V$SESSION s
           WHERE     s.STATUS = 'INACTIVE'
                 AND username = 'SCPOMGR'
                 AND OSUSER = 'scpoadm'
                 AND SQL_ID = '3m07b861v6tws'
                 AND PROGRAM = 'JDBC Thin Client')
   LOOP
      EXECUTE IMMEDIATE
         'ALTER SYSTEM KILL SESSION ''' || i.sid || ',' || i.serial || '''';

      DBMS_OUTPUT.put_line ('Session killed :' || i.sid || ',' || i.serial);
   END LOOP;
END;
/

ORACLE: some hidden parameters details

I compared the Database parameters with PROD DB running in XXDFFGPRDDB and I found the following differences.  If we have same resources and file system configuration  in PROD and QA, and the issue only happens in QA, then we should change the parameters in QA to match those in PROD. 

Please get PM approval for changing the following parameters in QA to match those in PROD.

PROD DB in  XXDFFGPRDDB
============================
streams_pool_size        = 512M
pga_aggregate_limit     = 12G
filesystemio_options    = "ASYNCH"
undo_retention            = 40000

The following hidden parameters are only in PROD:
_disable_streams_pool_auto_tuning= TRUE                       ß this is a workaround for unpublished Bug 24560906 for EXPDP And IMPDP Slow Performance.
_optimizer_gather_stats_on_load= FALSE                            ß changed was made on Dec 13 11:42:08 2016.  this is a workaround for Bug 19695624 - ORA-600 [qctfrc : bfc] reported during online statistics gathering (Doc ID 19695624.8)
_smu_debug_mode          = 33554432                                    ß changed was made on Jan 20 08:31:26 2017 .  this is a workaround for Bug 5387030 - Automatic tuning of undo_retention causes unusual extra space allocation (Doc ID 5387030.8).  The default value of _smu_debug_mode is 0.   

_smu_debug_mode          = 33554432” causes the v$undostat.tuned_undoretention to be calculated as
  the maximum of:
    maxquerylen secs + 300
    undo_retention specified in init.ora


QA DB in XXDFFGQADB 
============================
streams_pool_size        = 192M
pga_aggregate_limit     = 24G
filesystemio_options    = "SETALL"
undo_retention             = 10800

I reviewed Things To Consider For Setting filesystemio_options And disk_asynch_io (Doc ID 1987437.1) and found the following information:
The parameter filesystemio_options controls whether asynchronous and/or direct I/O is attempted for Oracle files available through a file system.  The parameter has no effect on disk accesses that bypass the OS file system layer—such disk access always uses direct I/O.  Raw files, files on ASM, files on the Veritas file system when accessed using Oracle Disk Manager (ODM), and files accessed using Direct NFS (dNFS) all bypass the file system layer, so this parameter is ignored in all such cases.

The following settings are available for this parameter:


Synchronous I/O
Asynchronous I/O
Buffered I/O
none
asynch
Direct I/O
directIO
setall

Thursday, October 5, 2017

Why resource manager needs to be disabled?

http://dbakevin.blogspot.in/2012/04/test.html

http://dbakevin.blogspot.in/2012/11/resmgrcpu-quantum.html?m=1

This is taken from oracle:

SYMPTOMS

Issuing a sqlplus / as sysdba might be hanging and/or high waits on event 'resmgr:cpu quantum' might be noticed even when resource manager is disabled.    
You already have confirmed parameter RESOURCE_MANAGER_PLAN is set to null but still noticing the above wait events.

Top 5 Timed Foreground Events:
Event                    Waits   Time(s)  Avg wait(ms) % DB time Wait Class

------------------------ ------- -------- ------------ -------------- ---------- -----------


resmgr:cpu quantum         1,596  346,281       216968          89.19 Scheduler


db file scattered read   171,071   14,778           86           3.81 User I/O


log file sync             28,575   10,810          378           2.78 Commit


db file sequential read  943,457   6,569             7           1.69 User I/O


DB CPU                     2,133   0.55

CAUSE

This is due to DEFAULT_MAINTENANCE_PLAN. From 11g onwards every weekday window has a pre-defined Resource Plan called DEFAULT_MAINTENANCE_PLAN, which will become active once the related window opens. In 10gR2, DEFAULT_MAINTENANCE_PLAN is associated with WEEKNIGHT_WINDOW and WEEKEND_WINDOW.

Following entries can also be noted in alert log at the time of issue.
Wed Sep 16 02:00:00 2009
Clearing Resource Manager plan via parameter
:
Wed Sep 16 22:00:00 2009
Setting Resource Manager plan SCHEDULER[0x2C55]:DEFAULT_MAINTENANCE_PLAN via scheduler window
Setting Resource Manager plan DEFAULT_MAINTENANCE_PLAN via parameter
Wed Sep 16 22:00:05 2009
Begin automatic SQL Tuning Advisor run for special tuning task "SYS_AUTO_SQL_TUNING_TASK"

SOLUTION

Please review the following document first to address any known bugs:

Note 392037.1 - Database 'Hangs'. Sessions Wait for 'resmgr:cpu quantum'
Note 1339803.1   Recommended Patches for CPU Resource Manager
It may be better to move the maintenance windows to a time of day when CPU resources might be more available for such tasks to run and complete.
The following solution should only be used as a last resort because it may lead to other issues in the long run if Oracle has inadequate maintenance windows to collect new optimizer stats, find better execution plans for expensive SQL, purge AWR, etc.
The steps provided should not disable the Automated Database Maintenance Tasks or the maintenance window , but will only remove the DEFAULT_MAINTENANCE_PLAN resource manager plan assigned to it and should work normally with no resource manager plan.

To disable the DEFAULT_MAINTENANCE_PLAN you can use the below steps as suggested in Note 786346.1

1. Set the current resource manager plan to null (or another plan that is not restrictive):
alter system set resource_manager_plan='' scope=both;

2. Change the active windows to use the null resource manager plan (or other nonrestrictive plan) using:
execute dbms_scheduler.set_attribute('WEEKNIGHT_WINDOW','RESOURCE_PLAN',''); 
execute dbms_scheduler.set_attribute('WEEKEND_WINDOW','RESOURCE_PLAN','');
Since in 11g there are more Maintenance Windows, we should add them too:
execute dbms_scheduler.set_attribute('SATURDAY_WINDOW','RESOURCE_PLAN',''); 
execute dbms_scheduler.set_attribute('SUNDAY_WINDOW','RESOURCE_PLAN','');
execute dbms_scheduler.set_attribute('MONDAY_WINDOW','RESOURCE_PLAN',''); 
execute dbms_scheduler.set_attribute('TUESDAY_WINDOW','RESOURCE_PLAN','');
execute dbms_scheduler.set_attribute('WEDNESDAY_WINDOW','RESOURCE_PLAN',''); 
execute dbms_scheduler.set_attribute('THURSDAY_WINDOW','RESOURCE_PLAN','');
execute dbms_scheduler.set_attribute('FRIDAY_WINDOW','RESOURCE_PLAN','');

3. Then, for each window_name (WINDOW_NAME from DBA_SCHEDULER_WINDOWS), run:
execute dbms_scheduler.set_attribute('<window name>','RESOURCE_PLAN','');