以下内容转自网络。
在oracle 9i中。我们可以根据v$undostat的信息,估算出这个时期需要的undo表空间大小
以下是计算需要的undo表空间平均值的sql语句
select
ur undo_retention,
dbs db_block_size,
((ur * (ups * dbs)) + (dbs * 24)) / 1024 / 1024 as "M_bytes"
from (select value as ur
from v$parameter
where name = 'undo_retention'),
(select (sum(undoblks) / sum(((end_time - begin_time) * 86400))) ups
from v$undostat),
(select value as dbs
from v$parameter
where name = 'db_block_size')
以下是计算需要的undo表空间平均值的sql语句
select
ur undo_retention,
dbs db_block_size,
((ur * (ups * dbs)) + (dbs * 24)) / 1024 / 1024 as "M_bytes"
from (select value as ur
from v$parameter
where name = 'undo_retention'),
(select (sum(undoblks) / sum(((end_time - begin_time) * 86400))) ups
from v$undostat),
(select value as dbs
from v$parameter
where name = 'db_block_size')
另外,以下是按照峰值计算需要的undo表空间的sql语句
select
ur undo_retention,
dbs db_block_size,
((ur * (ups * dbs)) + (dbs * 24)) / 1024 / 1024 as "M_bytes"
from (select value as ur
from v$parameter
where name = 'undo_retention'),
(select (undoblks / ((end_time - begin_time) * 86400)) ups
from v$undostat where undoblks in (select max(undoblks) from v$undostat ) ),
(select value as dbs
from v$parameter
where name = 'db_block_size')
select
ur undo_retention,
dbs db_block_size,
((ur * (ups * dbs)) + (dbs * 24)) / 1024 / 1024 as "M_bytes"
from (select value as ur
from v$parameter
where name = 'undo_retention'),
(select (undoblks / ((end_time - begin_time) * 86400)) ups
from v$undostat where undoblks in (select max(undoblks) from v$undostat ) ),
(select value as dbs
from v$parameter
where name = 'db_block_size')
建议按照峰值估算和分配undo表空间大小,可能会浪费些存储空间,但是能够避免应用程序潜在的undo空间不够问题。
oracle 10g 的监控方法:
select to_char(begin_time,'yyyy-mm-dd hh24:mi:ss') begin_time,to_char(end_time,'yyyy-mm-dd hh24:mi:ss'),unxpstealcnt,unxpblkrelcnt,unxpblkreucnt,ssolderrcnt from v$undostat;