(ur) undo_retention in seconds
(ups) number of undo data blocks generated per second
(dbs) overhead varies based on extent and file size (db_block_size)
undospace = [ur * (ups * dbs)] + (dbs * 24)
上面的公式中,,第1、3个参数都可以轻松的从参数文件中得到:
sql> show parameter undo_retention
name type value
------------------------------------ ----------- ------------------------------
undo_retention integer 5400
sql> show parameter db_block_size
name type value
------------------------------------ ----------- ------------------------------
db_block_size integer 8192
现在重要的是要确定第2个参数:每秒钟生成undo block的总数,可以从 v$undostat 中得到。
每秒生成的undo量:
sql> select (sum(undoblks))/ sum((end_time - begin_time) * 86400) from v$undostat;
(sum(undoblks))/sum((end_time-begin_time)*86400)
--------------------------------------------------------------
117.97590055
正常估算值:
select (ur * (ups * dbs)) + (dbs * 24) as bytes
from (select value as ur from v$parameter where name = 'undo_retention'),
(select (sum(undoblks)/sum(((end_time - begin_time)*86400))) as ups from v$undostat),
(select block_size as dbs from dba_tablespaces where tablespace_name=
(select upper(value) from v$parameter where name = 'undo_tablespace'));
最大值估算:
select (ur * ups * dbs + dbs * 24) / 1024 / 1024 as undo size(m)
from (select value as ur from v$parameter where name = 'undo_retention'),
(select max(undoblks / ((end_time - begin_time) * 24 * 3600)) as ups from v$undostat),
(select value as dbs from v$parameter where name = 'db_block_size');
建议在业务量繁重的那一天进行统计,而将undo表空间大小设为最大估算值以上。
说明:本文整理于how to size undo tablespace for automatic undo management [id 262066.1]
