Oracle8: Database Administration 10-27 ......Obtaining Rollback Segment Information The OWNER column specifies the type of a rollback segment: OEM segments in the database.. Oracle8: Dat
Trang 1Oracle8: Database Administration 10-27
Obtaining Rollback Segment Information
The OWNER column specifies the type of a rollback segment:
OEM
segments in the database
the rollback segment
Trang 2Join the V$ROLLSTAT and V$ROLLNAME views to obtain the statistics of
the rollback segments currently used by the instance:
Example
SVRMGR> SELECT n.name, s.extents, s.rssize, s.optsize,
2> s.hwmsize, s.xacts, s.status
3> FROM v$rollname n, v$rollstat s
4> WHERE n.usn = s.usn;
NAME EXTENTS RSSIZE OPTSIZE HWMSIZE XACTS STATUS - - - - - - -
10-20 Copyright Oracle Corporation, 1998 All rights reserved.
Rollback Segment Statistics
V$ROLLNAME
USN
NAME
V$ROLLSTAT USN
EXTENTS RSSIZE XACTS OPTSIZE HWMSIZE AVEACTIVE STATUS CUREXT CURBLK
Trang 3Oracle8: Database Administration 10-29
Obtaining Rollback Segment Information
The columns in V$ROLLSTAT include :
Note
from V$ROLLSTAT view
ONLINE in DBA_ROLLBACK_SEGS
USN Rollback (undo) segment number; join with
V$ROLLNAME.USN to get the name EXTENTS Number of extents in the rollback segment
RSSIZE Current size of the segment in bytes
XACTS Number of transactions using this segment
OPTSIZE OPTIMAL value for the rollback segment
HWMSIZE High water mark; the maximum size in bytes to
which the segment grew since startup AVEACTIVE Current size of active extents, averaged over time STATUS Status of the rollback segment
(ONLINE indicates that the rollback segment is available for use PENDING OFFLINE indicates
offline has been executed and there are someactive transactions using the segment Therollback segment will be taken offline as soon
as all transactions using the rollback segmenthave beencompleted.)
CUREXT Current location of the rollback segment head; the
extent and block number CURBLK
Trang 4To check the use of rollback segment by currently active transactions, join the
V$TRANSACTION and V$SESSION views:
Example
SVRMGR> SELECT s.username, t.xidusn, t.ubafil,
2> t.ubablk, t.used_ublk
3> FROM v$session s, v$transaction t
4> WHERE s.saddr = t.ses_addr;
- - - -
10-21 Copyright Oracle Corporation, 1998 All rights reserved.
Rollback Segment: Current Activity
XIDUSN UBAFIL UBABLK UBASQN UBAREC STATUS
USED_UBLK USED_UREC
Trang 5Oracle8: Database Administration 10-31
Obtaining Rollback Segment Information
The relevant columns in V$TRANSACTION and their descriptions are
shown below:
SES_ADDR Address of the session; can be joined to
V$SESSION.SADDR XIDUSN Rollback (Undo) Segment Number used by the
transaction; used as part of the transaction ID UBAFIL The columns UBAFIL, UBABLK, UBASQN, and
UBAREC specify the current location in the rollback segment that the transaction is writing to UBABLK
UBASQN
UBAREC
USED_UBLK Number of blocks of undo generated by the
transaction START_UEXT Rollback segment extent from which the
transaction started writing START_UBAFIL Rollback segment file number from which the
transaction started writing START_UBABLK Rollback segment block number from which the
transaction started writing
Trang 6Troubleshooting Rollback Segment Problems
10-22 Copyright Oracle Corporation, 1998 All rights reserved.
Rollback Segment Problems
• Insufficient space for transactions
• Read-consistency error
• Blocking transaction
• Error in taking tablespace offline
Trang 7Oracle8: Database Administration 10-33
Troubleshooting Rollback Segment Problems
Possible Causes
A transaction cannot use multiple rollback segments and may fail because
there is insufficient space in the rollback segment (ORA-01562) This could
be caused by one of the following:
MAXEXTENTS and additional extents cannot be allocated
(ORA-01628)
Solution
If the tablespace does not have free space, increase the space available to the
tablespace by:
If a rollback segment cannot allocate more extents because the limit imposed
by MAXEXTENTS has been reached:
recurrence of the problem
10-23 Copyright Oracle Corporation, 1998 All rights reserved.
Insufficient Space for Transactions
• No space in tablespace
– Extend data files
– Allow automatic extension of data
files
– Add data files
• MAXEXTENTS reached for segment
– Increase MAXEXTENTS
– Recreate segments with larger extent
sizes
Trang 8Possible Causes
As shown in the section on Read-Consistency, the Oracle server guarantees
that a statement will only process data committed at a given time Any
changes that are not committed when the statement begins or are made after
the statement begins execution, will not be seen by the statement If the
Oracle server cannot construct a read-consistent image of data, the user will
receive an ORA-01555 SNAPSHOT TOO OLD error This error can occur
when the transaction that made the change has already committed and:
another transaction
10-24 Copyright Oracle Corporation, 1998 All rights reserved.
Read-Consistency Error
Image at statement commencement New image
Table
SELECT *
block
Trang 9Oracle8: Database Administration 10-35
Troubleshooting Rollback Segment Problems
Solution
Read-consistency errors can be minimized by ensuring that rollback
segments are created with:
Note that these errors cannot be avoided by increasing MAXEXTENTS
Instructor Note
There are other possible causes of the ORA-01555 error, which also occurs
when a read-consistent image cannot be constructed because the transaction
slot in the data block is reused
Trang 10Possible Causes
When an extent in a rollback segment is filled up, the Oracle server attempts
to reuse the next extent in the ring Even if this new extent contains one
active entry—that is, an entry that was written by a transaction that is still
active—it cannot be used In these cases, a rollback segment allocates an
additional extent The transaction cannot skip an extent in the ring and
continue writing to a subsequent extent A transaction that has made only a
few changes, but has been idle for a long time could cause rollback segments
to grow even though there are many free extents In such situations there is a
lot of space wasted and a database administrator may need to intervene to
avoid excessive rollback segment growth
10-25 Copyright Oracle Corporation, 1998 All rights reserved.
Blocking Session
Extent 3
Existing extent New extent
3 4
5 Blocking
session
Trang 11Oracle8: Database Administration 10-37
Troubleshooting Rollback Segment Problems
Detecting Blocking Sessions
Query V$ROLLSTAT, V$SESSION, and V$TRANSACTION views to find
any blocking transactions
Example
SVRMGR> SELECT s.sid, s.serial#, t.start_time, t.xidusn,
s.username
2> FROM v$session s, v$transaction t, v$rollstat r
3> WHERE s.saddr = t.ses_addr
4> AND t.xidusn = r.usn
5> AND ((r.curext = t.start_uext-1) OR
6> ((r.curext = r.extents-1) AND t.start_uext=0));
- - - -
1 row selected.
Check if the transaction can be ended or whether the transaction needs to be
killed, and take the necessary action
Trang 12Problem Diagnosis and Resolution
If a tablespace contains one or more active rollback segments, it cannot be
taken offline, and the session attempting to execute the statement will
receive an ORA-01546 error In this situation, perform the following steps:
the tablespace
2 Take all rollback segments in the tablespace offline
using these rollback segments
5 Terminate the sessions if necessary
6 Take the tablespace offline
10-26 Copyright Oracle Corporation, 1998 All rights reserved.
Error in Taking a Tablespace Offline
Cannot take tablespace containing active
• Find session ID and serial number
• Terminate the session, if necessary
Trang 13Oracle8: Database Administration 10-39
Summary
Summary
10-27 Copyright Oracle Corporation, 1998 All rights reserved.
Summary
• Creating adequate rollback segments
• Troubleshooting rollback segment
problems
Trang 14Quick Reference
Initialization parameters ROLLBACK_SEGMENTS
TRANSACTIONS TRANSACTIONS_PER_ROLLBACK_SEGMENTS MAX_ROLLBACK_SEGMENTS
Dynamic performance views V$ROLLNAME
V$ROLLSTAT V$TRANSACTION V$SESSION Data dictionary views DBA_ROLLBACK_SEGS
Commands CREATE ROLLBACK SEGMENT
ALTER ROLLBACK SEGMENT ONLINE ALTER ROLLBACK SEGMENT STORAGE ALTER ROLLBACK SEGMENT SHRINK ALTER ROLLBACK SEGMENT OFFLINE DROP ROLLBACK SEGMENT
SET TRANSACTION USE ROLLBACK SEGMENT
Trang 15
11
Managing Temporary
Segments
Trang 17Oracle8: Database Administration 11-3
• Allocating space for temporary
segments within a database
• Obtaining temporary segment
information for a database or instance
Trang 18Temporary Segment Usage
Temporary segments are used when statements such as the following are
executed and the Oracle server cannot perform the sorting needed in
The amount of memory used by a process for sorting is determined by the
SORT_AREA_SIZE initialization parameter If the sort volume exceeds this
size, several sort runs are needed, and intermediate results are stored on disk
Temporary segments are created and used by the Oracle server in the
11-3 Copyright Oracle Corporation, 1998 All rights reserved.
Temporary Segment
Data file Memory
SORT_AREA_SIZE
Trang 19Oracle8: Database Administration 11-5
Overview
Note
increasing it might increase the memory requirement significantly
Users.”
Oracle8: Performance Tuning.
Instructor Note
When using MTS, memory is allocated for sorts in the SGA
Trang 20Types of Temporary Segments
Temporary segments may be created either in a PERMANENT tablespace or
in a TEMPORARY tablespace A user may be assigned one of these types of
tablespaces for sorting
Temporary Tablespace
A TEMPORARY tablespace is used exclusively for temporary segments and
cannot have any other type of segment They can be created as
TEMPORARY by using the following command:
CREATE TABLESPACE tablespace_name TEMPORARY
DATAFILE filespec [autoextend_clause]
[ , filespec [autoextend_clause]]
A PERMANENT tablespace can be changed into a TEMPORARY
tablespace by using:
11-4 Copyright Oracle Corporation, 1998 All rights reserved.
Types of Temporary Segments
Temporary tablespace
Permanent tablespace
Memory
Trang 21Oracle8: Database Administration 11-7
Types of Temporary Segments
The Oracle server may create a temporary segment in a PERMANENT
tablespace if the following conditions are satisfied:
tablespace for sorting
If a PERMANENT tablespace is used for sorting, an instance may have
more than one temporary segment in the tablespace
A temporary segment is dropped by SMON on completion of a statement
and space is released for use by other objects If PERMANENT tablespaces
are used for sorting, the free space in the tablespace may be highly
fragmented So it is recommended that this tablespace be used exclusively
• Reclaimed by SMON when the
statement completes execution
Trang 22If TEMPORARY tablespaces are used for temporary segments, an instance
only creates one sort segment in this tablespace Several transactions
requiring disk sorts can use the same segment An extent cannot be shared
by multiple transactions
Use of Sort Segments
A sort segment is created by the first statement that uses a TEMPORARY
tablespace for sorting, after startup A sort segment created in a
TEMPORARY tablespace is released only at shutdown This decreases the
frequent allocation and deallocation of extents by operations needing sorts
and helps improve performance There is no limit to the number of extents
for a sort segment created in a TEMPORARY tablespace
Sort Extent Pool
11-6 Copyright Oracle Corporation, 1998 All rights reserved.
Temporary Segments
in a Temporary Tablespace
• Known as sort segments
• Only one segment per tablespace per
instance
• Created when the first disk sort occurs
in the instance after startup
• Reused by several transactions based
on information in the Sort Extent Pool
• Released on instance shutdown
Trang 23Oracle8: Database Administration 11-9
Allocating Space for Temporary Segments
Allocating Space for Temporary Segments
Create and use TEMPORARY tablespaces for sorting to improve
concurrency and to decrease frequent allocation and deallocation of space
The sizes of the extents used by a temporary segment are governed by the
DEFAULT STORAGE clause specified for the tablespace
Specifying Default Storage
Use the following guidelines to specify DEFAULT STORAGE:
SORT_AREA_SIZE to a temporary segment, a good value for the extent
size is (n*s + b)
where: n is a positive integer
s is the value of SORT_AREA_SIZE initialization parameter
b is the value of DB_BLOCK_SIZE initialization parameter
Using this value optimizes temporary segment usage by allowing for
sufficient space for a header block and multiple sort run data to be stored
in each extent
11-7 Copyright Oracle Corporation, 1998 All rights reserved.
Guidelines for Temporary Segments
• Set up different TEMPORARY tablespaces
based on sorting needs
• Specify DEFAULT STORAGE for these
tablespaces as shown:
– INITIAL= NEXT = (multiple of
SORT_AREA_SIZE) + DB_BLOCK_SIZE
– PCTINCREASE = 0
Trang 24• Specify a PCTINCREASE of zero to ensure that all extents are of the
same size
tablespace is a PERMANENT tablespace
Note
Create tablespaces with different default storage clauses and assign them to
users based on their sorting needs
Trang 25Oracle8: Database Administration 11-11
Obtaining Temporary Segment Information
Obtaining Temporary Segment Information
The following views can be used to obtain information about temporary
segments and their usage:
This view only shows currently active sorts for the instance
11-8 Copyright Oracle Corporation, 1998 All rights reserved.
Obtaining Information for a
Database Instance
DBA_SEGMENTS
V$SORT_SEGMENT
V$SORT_USAGE
Trang 26Query the V$SORT_SEGMENT view to check the TEMPORARY
tablespaces containing sort segments and their usage statistics:
The columns MAX_SORT_SIZE and MAX_SORT_BLOCKS specify the
number of extents and blocks used by the largest sort operation that used a
11-9 Copyright Oracle Corporation, 1998 All rights reserved.
Sort Segment Statistics
Trang 27Oracle8: Database Administration 11-13
Obtaining Temporary Segment Information
Join V$SESSION and V$SORT_USAGE views to obtain information on the
currently active sorts in the instance:
Example
SVRMGR> SELECT s.username, u."USER", u.tablespace,
2> u.contents, u.extents, u.blocks
3> FROM v$session s,v$sort_usage u
The USER column in V$SORT_USAGE always shows the user querying
this view and not the user performing the sort Always obtain the user name
from the V$SESSION view The CONTENTS column shows whether the
temporary segment is created in a PERMANENT or a TEMPORARY
tablespace
11-10 Copyright Oracle Corporation, 1998 All rights reserved.
Temporary Segment Activity
V$SESSION
SADDR USERNAME SID
V$SORT_USAGE
SESSION_ADDR TABLESPACE CONTENTS EXTENTS BLOCKS
Trang 28Quick Reference
Initialization parameters DB_BLOCK_SIZE
Dynamic initialization parameters
(deferred)
SORT_AREA_SIZE
Dynamic performance views V$SORT_SEGMENT
V$SORT_USAGE V$SESSION Data dictionary views DBA_SEGMENTS
Commands CREATE TABLESPACE TEMPORARY
ALTER TABLESPACE TEMPORARY ALTER TABLESPACE PERMANENT
11-11 Copyright Oracle Corporation, 1998 All rights reserved.