First is to check sysaux table space in the most space components and objects
select OCCUPANT_NAME,OCCUPANT_DESC,SPACE_USAGE_KBYTES/1024 USAGE_MB
from V$SYSAUX_OCCUPANTS order by SPACE_USAGE_KBYTES desc;
SELECT D.SEGMENT_NAME, D.SEGMENT_TYPE,SUM(BYTES)/1024/1024 SIZE_MB
FROM DBA_SEGMENTS D
WHERE D.TABLESPACE_NAME = 'SYSAUX'
GROUP BY D.SEGMENT_NAME, D.SEGMENT_TYPE
ORDER BY SIZE_MB DESC;
If you find that the problem of statistical information, can be cleaned as follows:
A law: purge (delete with the underlying delete)
Show the current history level:
select dbms_stats.get_stats_history_availability from dual;
Assuming history is 100 days old and you want to purge it until 10 days old:
begin
for i in reverse 10..100
loop
dbms_stats.purge_stats(sysdate-i);
end loop;
end;
/
Show the new history level
select dbms_stats.get_stats_history_availability from dual;
Act II: truncate
The next purge only when the situation is still not free up space, or too large to be deleted, it is recommended to clean up with a way to truncate.
Backup to delete the latest data base table
create table SYS.WRI$_OPTSTATHISTHEADHISTORYBAK as (select * from sys.wri$_optstat_histhead_history where savtime > SYSDATE - 14);
create table SYS.WRI$_OPTSTATHISTGRMHISTORYBAK as (select * from sys.WRI$_OPTSTAT_HISTGRM_HISTORY where savtime > SYSDATE - 14);
create table SYS.WRI$_OPTSTAT_TAB_BAK as (select * from sys.wri$_optstat_tab_history where savtime > SYSDATE - 14);
create table SYS.WRI$_OPTSTAT_IND_BAK as (select * from sys.wri$_optstat_ind_history where savtime > SYSDATE - 14);
View SM / OPTSTAT number of days (for storing old statistics) Reserved
select dbms_stats.get_stats_history_retention from dual;
Set Time SM / OPTSTAT reserved (-1 indicates unlimited)
exec dbms_stats.alter_stats_history_retention(-1);
truncate larger TABLE
truncate table sys.WRI$_OPTSTAT_HISTHEAD_HISTORY;
truncate table sys.WRI$_OPTSTAT_HISTGRM_HISTORY;
truncate table sys.wri$_optstat_ind_history;
truncate table sys.wri$_optstat_tab_history;
Cleanup historical statistics
exec dbms_stats.purge_stats(sysdate-300);
exec dbms_stats.purge_stats(sysdate-200);
exec dbms_stats.purge_stats(sysdate-100);
exec dbms_stats.purge_stats(sysdate-30);
The historical statistics retention time to 30 days
exec dbms_stats.alter_stats_history_retention(30);
select dbms_stats.get_stats_history_retention from dual;
The historical statistics related tables MOVE
alter table sys.WRI$_OPTSTAT_HISTHEAD_HISTORY move tablespace sysaux;
alter index sys.I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST rebuild online;
alter index sys.I_WRI$_OPTSTAT_HH_ST rebuild online;
...
alter table sys.WRI$_OPTSTAT_IND_HISTORY move tablespace sysaux;
alter index sys.I_WRI$_OPTSTAT_IND_OBJ#_ST rebuild online;
alter index sys.I_WRI$_OPTSTAT_IND_ST rebuild online;
MOVE tables of statistics collected
EXEC dbms_stats.gather_table_stats(ownname => 'SYS',tabname => 'WRI$_OPTSTAT_HISTGRM_HISTORY',cascade => TRUE);
...
EXEC dbms_stats.gather_table_stats(ownname => 'SYS',tabname => 'WRI$_OPTSTAT_HISTHEAD_HISTORY',cascade => TRUE);
reference
- http://zxf261.blog.51cto.com/701797/776496
- http://otn-world.blogspot.com/2014/06/purging-optimizer-stats.html
- http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_stats.htm#ARPLS68644