Gather SCHEMA Stats on SYS.

Here are below steps need to be followed while taking schema stats on SYS .

To Gather Dictionary Stats
--------------------------------
EXEC DBMS_STATS.GATHER_SCHEMA_STATS ('SYS');
EXEC DBMS_STATS.GATHER_DATABASE_STATS (gather_sys=>TRUE);
EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;

To Gather Fixed Objects Stats
----------------------------------
EXEC DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

To validate them..

SQL> select table_name, last_analyzed from dba_tables where owner='SYS' and table_name like '%$' order by 2;

SQL> Select OWNER,TABLE_NAME,LAST_ANALYZED,STALE_STATS from DBA_TAB_STATISTICS where STALE_STATS='YES';

As it might take long time to run,put all them in a script and run it as background job.

Sample Scripts
------------------

bash-3.2$ cat gather_xxint.sh
#!/bin/ksh

ORACLE_SID="XXDD"
ORACLE_HOME="/XXDD/oracle/product/102"
TNS_ADMIN="/XXDD/oracle/product/102/network/admin/XXDD_localhost01"
export ORACLE_SID ORACLE_HOME TNS_ADMIN

sqlplus -s "/as sysdba" <<EOF
show user
spool /XXDD/oracle/RFCExecution/3-4E9EQ9F/gather_stats.log
set timing on
set lines 300 pages 300

prompt 'Proceeding to gather stats on SYS'
EXEC DBMS_STATS.GATHER_SCHEMA_STATS ('SYS')
/

prompt 'Proceeding to gather database stats on SYS'
EXEC DBMS_STATS.GATHER_DATABASE_STATS (gather_sys=>TRUE)
/

prompt 'Proceeding to gather dictionary stats on SYS'
EXEC DBMS_STATS.GATHER_DICTIONARY_STATS
/

prompt 'Proceeding to gather fixed boject stats on SYS'
EXEC DBMS_STATS.GATHER_FIXED_OBJECTS_STATS
/

EOF
cat /XXDD/oracle/gather_stats.log |mailx -s "Gather stats for SYS Completed" abc.abc@domain.com

Comments