如何對undo表空間大小進行設置

1.對於undo表空間大小的設置須要參考三組數據

  1. (UR)每秒鐘的undo_retention
  2. (UPS)每秒鐘生成的undo數據塊的數量
  3. (DBS)undo表空間的db_block_size大小

2.undo表空間須要分配空間大小,經過一下公式進行計算

  其中兩個配置能夠在數據庫中直接查詢或配置:undo_retention和db_block_size,這個公式的第三部分須要到正在運行的數據庫中進行查詢,每秒鐘使用的undo數據塊能夠從v$undostat視圖中進行獲取。數據庫

UndoSpace = UR * (UPS * DBS)

3.下面的公式計算每秒使用的峯值undo塊

  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);

4.下面的查詢計算處理峯值undo活動所需的字節數

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'));

5.對於10G以上的版本使用下面的SQL語句進程查詢

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'));

  

6.下面對實際生產庫進行查詢檢驗

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
相關文章
相關標籤/搜索