2、诊断rollback segment header的竞争
如果rollback segment 由手工管理,下列措施诊断rollback segment header的竞争
SELECT class,count FROM v$waitstat WHERE class LIKE ''%undo%'' ;
SELECT Sum(Value) sum FROM v$sysstat WHERE NAME IN (''db block gets'',''consistent gets'');
任何类型的等待次数(count)与总请求数(sum)的比率,不能超过1%。
或
select sum(waits)*100/sum(gets) "Ratio", sum(waits) "Waits", sum(gets) "Gets" from v$rollstat;
waits的汇总数与gets的汇总数的比率应低于1%,如果超过1%,应创建更多的rollback segment。
3、消耗更少的rollback segment
1)如果是删除表里所有的数据,尽可能使用trauncate而不是delete。
2)在应用中允许用户有规律的提交,尽可能不用长事务。
3)· Import
– Set COMMIT = Y
– Size the set of rows with BUFFER
· Export: Set CONSISTENT=N
· SQL*Loader: Set the COMMIT intervals with ROWS
估计undo tablespace大小的公式:
Undo space = (undo_retention * (undo blocks per second * db_block_size)) + db_block_size;
可以使用下列的sql设定undo_retention和undo tablespace:
select (rd*(ups*overhead)+overhead) "bytes" from (select value rd from v$parameter where name =''undo_retention''),(select (sum(undoblks)/sum(((end_time-begin_time)*10800))) ups from v$undostat),(select value overhead from v$parameter where name=''db_block_size'');
其中:
Rd:undo_retention设置的时间;
Ups:undo blocks per second;
Overhead:rollback segment header;