SlideShare a Scribd company logo
Anar Godjaev

Undo Management
optimal undo_retention parameter = actual undo size /
(db_block_size/undo_block_per_sec)
-- **********************
-- manual undo management
-- **********************

create rollback segment r01 tablespacerbs;
create public rollback_segment r01 tablespacerbs;
alter rollback segment r01 offline;
drop rollback segment r01;
-- *************************
-- automatic undo management
-- *************************
alter system set undo_management = auto;
alter system set undo_tablespace = <ts_name>;
alter system set undo_suppress_errors = true|false ;
alter system set undo_retention = 900; --seconds
select name, value from v$parameter where name like
'undo_management'
select name, value from v$parameter where name like
'undo_tablespace'
select name, value from v$parameter where name like
'undo_retention'
-- creating undo tablespace
create undo tablespacets_undodatafile 'C:ts_undo_01.dbf' size
20m;
alter tablespacets_undo add datafile 'C:ts_undo_02.dbf' size
40m;
alter system set undo_tablespace = ts_undo;
drop tablespacets_undo;
alter tablespacets_undo retention guarantee;
select retention, tablespace_name from dba_tablespaces;
Anar Godjaev
select begin_time, end_time, tuned_undoretention from
v$undostat;
-- calculating undo space
select
ceil(((UR * (UPS * DBS)) + (DBS * 24))/1024/1024) as MB
from
(select value as UR from v$parameter where
name='undo_retention'),
(select (sum(undoblks)/sum(((end_time - begin_time) * 84600)))
as UPS
from v$undostat),
(select value as DBS from v$parameter where name =
'db_block_size');
set transaction read only;
set transaction isolation level serializable; -- possible
negative impact on performance
-- Actual Undo Size
SELECT SUM(a.bytes) "UNDO_SIZE"
FROM v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.ts# = b.ts#;
-- Undo Blocks per Second
SELECT MAX(undoblks/((end_time-begin_time)*3600*24))
"UNDO_BLOCK_PER_SEC"
FROM v$undostat;
-- DB Block Size
SELECT TO_NUMBER(value) "DB_BLOCK_SIZE [KByte]"
FROM v$parameter
WHERE name = 'db_block_size';
Anar Godjaev

-- optimal undo retention
SELECT d.undo_size/(1024*1024) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
ROUND((d.undo_size / (to_number(f.value) *
g.undo_block_per_sec)))
"OPTIMAL UNDO RETENTION [Sec]"
FROM (
SELECT SUM(a.bytes) undo_size
FROM v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.ts# = b.ts#
) d,
v$parameter e,
v$parameter f,
( SELECT MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec FROM v$undostat ) g
WHERE e.name = 'undo_retention'
AND f.name = 'db_block_size';
-- optimal undo size
SELECT d.undo_size/(1024*1024) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
(TO_NUMBER(e.value) * TO_NUMBER(f.value) *
g.undo_block_per_sec) / (1024*1024)
"NEEDED UNDO SIZE [MByte]"
FROM (
SELECT SUM(a.bytes) undo_size
FROM v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.ts# = b.ts#
Anar Godjaev
) d,
v$parameter e,
v$parameter f,
(
SELECT MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
FROM v$undostat
) g
WHERE e.name = 'undo_retention'
AND f.name = 'db_block_size';
-- undo consumer sessions
SELECT
TO_CHAR (s.SID) || ',' || TO_CHAR (s.serial#) sid_serial,
NVL (s.username, 'None') orauser,
s.program,
r.NAME undoseg,
t.used_ublk * TO_NUMBER (x.VALUE) / 1024 || 'K' "Undo",
t1.tablespace_name
FROM
SYS.v_$rollname r,
SYS.v_$session s,
SYS.v_$transaction t,
SYS.v_$parameter x,
dba_rollback_segs t1
WHERE
s.taddr = t.addr
AND r.usn = t.xidusn(+)
AND x.NAME = 'db_block_size'
AND t1.segment_id = r.usn
AND t1.tablespace_name = 'UNDOTBS1';

More Related Content

TXT
Litebox
PPTX
Super Advanced Python –act1
PPTX
Windows Server 2012 Active Directory Recovery
DOCX
Parallel Server
PPTX
Fixing Web Data in Production
PDF
ClickHouse materialized views - a secret weapon for high performance analytic...
PDF
Circular queue
PDF
Synchronisation de périphériques avec Javascript et PouchDB
Litebox
Super Advanced Python –act1
Windows Server 2012 Active Directory Recovery
Parallel Server
Fixing Web Data in Production
ClickHouse materialized views - a secret weapon for high performance analytic...
Circular queue
Synchronisation de périphériques avec Javascript et PouchDB

What's hot (19)

PDF
Pymongo for the Clueless
DOC
Atm machine using c++
PDF
pg_proctab: Accessing System Stats in PostgreSQL
DOC
Atm machine using c++
PDF
Applying Real-time SQL Changes in your Hazelcast Data Grid
PDF
Python sqlite3
DOC
Atm machine using c++
DOC
Atm machine using c++
PPTX
Pm 4.0 permission_storage
PDF
Linear queue
PDF
Doubly Linked List
PPTX
Python queue solution with asyncio and kafka
PDF
Профилирование и оптимизация производительности Ruby-кода
PPTX
ヘルパ・オブジェクト
PDF
PowerCMS X
TXT
Afte DDL on Database PL/SQL Code
PDF
STACK IMPLEMENTATION USING SINGLY LINKED LIST
TXT
PDF
MongoUK - PHP Development
Pymongo for the Clueless
Atm machine using c++
pg_proctab: Accessing System Stats in PostgreSQL
Atm machine using c++
Applying Real-time SQL Changes in your Hazelcast Data Grid
Python sqlite3
Atm machine using c++
Atm machine using c++
Pm 4.0 permission_storage
Linear queue
Doubly Linked List
Python queue solution with asyncio and kafka
Профилирование и оптимизация производительности Ruby-кода
ヘルパ・オブジェクト
PowerCMS X
Afte DDL on Database PL/SQL Code
STACK IMPLEMENTATION USING SINGLY LINKED LIST
MongoUK - PHP Development
Ad

Similar to Undo Management (20)

PDF
How to calculate the optimal undo retention in Oracle
PPT
Less10 undo
DOC
Flashback (Practical Test)
PDF
2009 Collaborate IOUG Presentation
PDF
Beginbackup
PPT
Less10 Undo
DOC
br_test_lossof-datafile_10g.doc
DOCX
Backup and Recovery
PPTX
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
PPTX
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
PDF
Ensuring Data Protection Using Oracle Flashback Features
PPTX
Clase 11 manejo tablas modificada
PPTX
Clase 11 manejo tablas modificada
PDF
Debunking myths about_redo_ppt
TXT
Scripts related to temp tablespace
PDF
Tips and tricks to optimiza SQL Server Backup and Restore
PDF
ILOUG 2019 - Flashback, the forgotten feature
PPT
1 Oracle Flashback study related with recyclebin.ppt
PDF
Flashback ITOUG
PDF
Database & Technology 1 _ Clancy Bufton _ Flashback Query - oracle total reca...
How to calculate the optimal undo retention in Oracle
Less10 undo
Flashback (Practical Test)
2009 Collaborate IOUG Presentation
Beginbackup
Less10 Undo
br_test_lossof-datafile_10g.doc
Backup and Recovery
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
Ensuring Data Protection Using Oracle Flashback Features
Clase 11 manejo tablas modificada
Clase 11 manejo tablas modificada
Debunking myths about_redo_ppt
Scripts related to temp tablespace
Tips and tricks to optimiza SQL Server Backup and Restore
ILOUG 2019 - Flashback, the forgotten feature
1 Oracle Flashback study related with recyclebin.ppt
Flashback ITOUG
Database & Technology 1 _ Clancy Bufton _ Flashback Query - oracle total reca...
Ad

More from Anar Godjaev (20)

DOCX
Oracle GoldenGate
DOCX
Asm disk group migration from
DOCX
How to protect your sensitive data using oracle database vault / Creating and...
DOCX
how to protect your sensitive data using oracle database vault
DOCX
Database Vault / Verinin Güvenliği
DOCX
Oracle Golden Gate
PDF
Oracle 10g Database Server Kurulum
DOCX
DataPump ile Single Parititon Export
DOCX
Redologlar ve Yöneti̇mi̇
DOCX
Contraints
DOCX
Oracle SQL
DOCX
Veri̇tabani ve Kullanici Yöneti̇mi̇
DOCX
Instance ve Media Bozukluklarını Inceleme
DOCX
Conditional Control
DOCX
PL/SQL Blocks
DOCX
Wait Interface
DOCX
Audit Mekani̇zmasi
DOCX
Tuning SGA
DOCX
Table Partitions
DOCX
Memory Management
Oracle GoldenGate
Asm disk group migration from
How to protect your sensitive data using oracle database vault / Creating and...
how to protect your sensitive data using oracle database vault
Database Vault / Verinin Güvenliği
Oracle Golden Gate
Oracle 10g Database Server Kurulum
DataPump ile Single Parititon Export
Redologlar ve Yöneti̇mi̇
Contraints
Oracle SQL
Veri̇tabani ve Kullanici Yöneti̇mi̇
Instance ve Media Bozukluklarını Inceleme
Conditional Control
PL/SQL Blocks
Wait Interface
Audit Mekani̇zmasi
Tuning SGA
Table Partitions
Memory Management

Undo Management

  • 1. Anar Godjaev Undo Management optimal undo_retention parameter = actual undo size / (db_block_size/undo_block_per_sec) -- ********************** -- manual undo management -- ********************** create rollback segment r01 tablespacerbs; create public rollback_segment r01 tablespacerbs; alter rollback segment r01 offline; drop rollback segment r01; -- ************************* -- automatic undo management -- ************************* alter system set undo_management = auto; alter system set undo_tablespace = <ts_name>; alter system set undo_suppress_errors = true|false ; alter system set undo_retention = 900; --seconds select name, value from v$parameter where name like 'undo_management' select name, value from v$parameter where name like 'undo_tablespace' select name, value from v$parameter where name like 'undo_retention' -- creating undo tablespace create undo tablespacets_undodatafile 'C:ts_undo_01.dbf' size 20m; alter tablespacets_undo add datafile 'C:ts_undo_02.dbf' size 40m; alter system set undo_tablespace = ts_undo; drop tablespacets_undo; alter tablespacets_undo retention guarantee; select retention, tablespace_name from dba_tablespaces;
  • 2. Anar Godjaev select begin_time, end_time, tuned_undoretention from v$undostat; -- calculating undo space select ceil(((UR * (UPS * DBS)) + (DBS * 24))/1024/1024) as MB from (select value as UR from v$parameter where name='undo_retention'), (select (sum(undoblks)/sum(((end_time - begin_time) * 84600))) as UPS from v$undostat), (select value as DBS from v$parameter where name = 'db_block_size'); set transaction read only; set transaction isolation level serializable; -- possible negative impact on performance -- Actual Undo Size SELECT SUM(a.bytes) "UNDO_SIZE" FROM v$datafile a, v$tablespace b, dba_tablespaces c WHERE c.contents = 'UNDO' AND c.status = 'ONLINE' AND b.name = c.tablespace_name AND a.ts# = b.ts#; -- Undo Blocks per Second SELECT MAX(undoblks/((end_time-begin_time)*3600*24)) "UNDO_BLOCK_PER_SEC" FROM v$undostat; -- DB Block Size SELECT TO_NUMBER(value) "DB_BLOCK_SIZE [KByte]" FROM v$parameter WHERE name = 'db_block_size';
  • 3. Anar Godjaev -- optimal undo retention SELECT d.undo_size/(1024*1024) "ACTUAL UNDO SIZE [MByte]", SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]", ROUND((d.undo_size / (to_number(f.value) * g.undo_block_per_sec))) "OPTIMAL UNDO RETENTION [Sec]" FROM ( SELECT SUM(a.bytes) undo_size FROM v$datafile a, v$tablespace b, dba_tablespaces c WHERE c.contents = 'UNDO' AND c.status = 'ONLINE' AND b.name = c.tablespace_name AND a.ts# = b.ts# ) d, v$parameter e, v$parameter f, ( SELECT MAX(undoblks/((end_time-begin_time)*3600*24)) undo_block_per_sec FROM v$undostat ) g WHERE e.name = 'undo_retention' AND f.name = 'db_block_size'; -- optimal undo size SELECT d.undo_size/(1024*1024) "ACTUAL UNDO SIZE [MByte]", SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]", (TO_NUMBER(e.value) * TO_NUMBER(f.value) * g.undo_block_per_sec) / (1024*1024) "NEEDED UNDO SIZE [MByte]" FROM ( SELECT SUM(a.bytes) undo_size FROM v$datafile a, v$tablespace b, dba_tablespaces c WHERE c.contents = 'UNDO' AND c.status = 'ONLINE' AND b.name = c.tablespace_name AND a.ts# = b.ts#
  • 4. Anar Godjaev ) d, v$parameter e, v$parameter f, ( SELECT MAX(undoblks/((end_time-begin_time)*3600*24)) undo_block_per_sec FROM v$undostat ) g WHERE e.name = 'undo_retention' AND f.name = 'db_block_size'; -- undo consumer sessions SELECT TO_CHAR (s.SID) || ',' || TO_CHAR (s.serial#) sid_serial, NVL (s.username, 'None') orauser, s.program, r.NAME undoseg, t.used_ublk * TO_NUMBER (x.VALUE) / 1024 || 'K' "Undo", t1.tablespace_name FROM SYS.v_$rollname r, SYS.v_$session s, SYS.v_$transaction t, SYS.v_$parameter x, dba_rollback_segs t1 WHERE s.taddr = t.addr AND r.usn = t.xidusn(+) AND x.NAME = 'db_block_size' AND t1.segment_id = r.usn AND t1.tablespace_name = 'UNDOTBS1';