How to set the size of the undo tablespace

1. For setting the size of the undo tablespace, you need to refer to three sets of data

  1. (UR) undo_retention per second
  2. (UPS) Number of undo blocks generated per second
  3. (DBS) db_block_size size of undo tablespace

2. The undo tablespace needs to allocate the space size, which is calculated by the following formula

  Two of the configurations can be directly queried or configured in the database: undo_retention and db_block_size. The third part of this formula needs to be queried in the running database. The undo data blocks used per second can be obtained from the v$undostat view. .

UndoSpace = UR * (UPS * DBS)

3. The following formula calculates the peak undo blocks used per second

  ENT_TIME and BEGIN_TIME are time data types. ENT_TIME minus BEGIN_TIME is the number of days in these two time periods. Converting the number of days to seconds needs to be multiplied by 86400, the description of one day (24*60*60)

SELECT undoblks/((end_time-begin_time)*86400) "Peak Undo Block Generation" FROM v$undostat WHERE undoblks=(SELECT MAX(undoblks) FROM v$undostat);

4. The following query calculates the number of bytes required to handle peak undo activity

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. For the version above 10G, use the following SQL statement to process the query

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. Check the actual production library below

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

  

View the size of the undo tablespace

SQL> select sum(bytes/1024/1024/1024) "undo sizeG" from dba_data_files where TABLESPACE_NAME='UNDOTBS1';

     undo sizeG
---------------
  39.9462890625

  

After the above comparison, it is found that the actual allocated undo table space is far larger than the calculated space size, and there must be an ORA-01555 error in the alert log recently.

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

  

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325000055&siteId=291194637