其中兩個配置能夠在數據庫中直接查詢或配置:undo_retention和db_block_size,這個公式的第三部分須要到正在運行的數據庫中進行查詢,每秒鐘使用的undo數據塊能夠從v$undostat視圖中進行獲取。數據庫
UndoSpace = UR * (UPS * DBS)
ENT_TIME和BEGIN_TIME是時間數據類型,ENT_TIME減去BEGIN_TIME,就是這兩個時間段的天數,將天數轉換爲秒數須要乘以86400,一天的描述(24*60*60)spa
SELECT undoblks/((end_time-begin_time)*86400) "Peak Undo Block Generation" FROM v$undostat WHERE undoblks=(SELECT MAX(undoblks) FROM v$undostat);
SELECT (UR * (UPS * DBS)) AS "Bytes" FROM (SELECT value AS UR FROM v$parameter WHERE name = 'undo_retention'), (SELECT undoblks / ((end_time - begin_time) * 86400) AS UPS FROM v$undostat WHERE undoblks = (SELECT MAX(undoblks) 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)) AS "Bytes" FROM (select max(tuned_undoretention) AS UR from v$undostat), (SELECT undoblks / ((end_time - begin_time) * 86400) AS UPS FROM v$undostat WHERE undoblks = (SELECT MAX(undoblks) FROM v$undostat)), (SELECT block_size AS DBS FROM dba_tablespaces WHERE tablespace_name = (SELECT UPPER(value) FROM v$parameter WHERE name = 'undo_tablespace'));
SQL> set num 15 SQL> SELECT (UR * (UPS * DBS)) AS "Bytes" 2 FROM (select max(tuned_undoretention) AS UR from v$undostat), 3 (SELECT undoblks / ((end_time - begin_time) * 86400) AS UPS 4 FROM v$undostat 5 WHERE undoblks = (SELECT MAX(undoblks) FROM v$undostat)), 6 (SELECT block_size AS DBS 7 FROM dba_tablespaces 8 WHERE tablespace_name = 9 (SELECT UPPER(value) 10 FROM v$parameter 11 WHERE name = 'undo_tablespace')); Bytes --------------- 63436368964.267 SQL> select 63436368964/1024/1024/1024 from dual; 63436368964/1024/1024/1024 -------------------------- 59.07972246781
查看undo表空間的大小日誌
SQL> select sum(bytes/1024/1024/1024) "undo sizeG" from dba_data_files where TABLESPACE_NAME='UNDOTBS1'; undo sizeG --------------- 39.9462890625
通過上面的對比,發現實際分配的undo表空間比計算獲得的空間大小差距較大,alert日誌中最近必定存在ORA-01555錯誤code
Tue Apr 24 15:41:44 2018 ORA-01555 caused by SQL statement below (SQL ID: 7ng6c01huuk1s, Query Duration=6 sec, SCN: 0x0022.1c41386c): Tue Apr 24 15:41:44 2018