关于oracle undo回滚段v$undostat的一点理解与分析

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:796

ORACLE v$undostat 视图,觉得这个视图对查看UNDO的使用的使用情况非常有用,可以说可以确定出
你的UNDO tablespace是否合理,这里还注意一点,就是TYPE2 UNDO这个类型是使用撤销段而不是使用传统的回退段的时候的段类型。

本视图监控当前实例中undo空间以及事务如何运行。并统计undo空间开销,事务开销以及实例可用的查询长度。
V$UNDOSTAT中的常用列l Endtime:以10分钟为间隔的结束时间l UndoBlocksUsed:使用的undo块总数l TxnConcurrency:事务并发执行的最大数l TxnTotal:在时间段内事务执行总数l QueryLength:查询长度的最大值l ExtentsStolen:在时间段内undo区必须从一个undo段转到另一个的次数l SSTooOldError:在时间段内'Snapshot Too Old'错误发生的次数l UNDOTSN:这段时间内最后活动的undo表空间ID  视图的第一行显示了当前时间段的统计,其它的每一条记录分别以每10分钟一个区间。24小时循环,一天最多144条记录。

对所有字段进行逐一解释:
BEGIN_TIME : Identifies the beginning of the time interval
本视图采用每10分钟进行分割,这个字段是一个分割的起始时间。

END_TIME : Identifies the end of the time interval
这个字段是一个分割的结束时间。

UNDOTSN : Represents the last active undo tablespace in the duration of time.
这个字段理解得不清楚,大概是时间段内活动的撤销表空间。

UNDOBLKS : Represents the total number of undo blocks consumed. You can use this
column to obtain the consumption rate of undo blocks, and thereby
estimate the size of the undo tablespace needed to handle the workload on
your system.
这个字段显示了这段时间以来总的消耗的撤销块的大小,可以用来估计你的撤销表空间设置是否合理。

TXNCOUNT : Identifies the total number of transactions executed within the period
显示了这段时间以来的总的事物总量。

MAXQUERYLEN : Identifies the length of the longest query (in seconds) executed in the
instance during the period. You can use this statistic to estimate the proper
setting of the UNDO_RETENTION initialization parameter. The length of a
query is measured from the cursor open time to the last fetch/execute
time of the cursor. Only the length of those cursors that have been
fetched/executed during the period are refected in the view.
这个字段显示了这段时间以来最长的查询,为了防止快照太旧的情况,可以通过这个字段来设置UNDO_RETENTION参数的大小

MAXQUERYID : SQL identifier of the longest running SQL statement in the period
显示了运行最长时间的sql_id,可以通过这个字段查询出运行时间最长的SQL(连接v$sql视图)

MAXCONCURRENCY : Identifies the highest number of transactions executed concurrently within
the period
显示了本段时间以来事务并发执行的最大数。

UNXPSTEALCNT : Number of attempts to obtain undo space by stealing unexpired extents
from other transactions
当撤销表空间不足以保存UNDO_RETENTION参数所指定的时间的时候,就会尝试使用没有过期的撤销空间,当然这个字段为0最好

UNXPBLKRELCNT : Number of unexpired blocks removed from certain undo segments so they
can be used by other transactions
同上这个字段使用块为单位

UNXPSTEALCNT : Number of attempts to obtain undo space by stealing unexpired extents
from other transactions
这个字段是以分区为单位

UNXPBLKRELCNT : Number of unexpired blocks removed from certain undo segments so they
can be used by other transactions

UNXPBLKREUCNT : Number of unexpired undo blocks reused by transactions
EXPSTEALCNT NUMBER Number of attempts to steal expired undo blocks from other undo
segments

EXPBLKRELCNT : Number of expired undo blocks stolen from other undo segments

EXPBLKREUCNT : Number of expired undo blocks reused within the same undo segments
我觉得以上的几个字段都是由于撤销表空间不足而导致的,最好都为0.

select * from v$undostat;
End-Time UndoBlocks TxnConcrcy TxnTotal QueryLen ExtentsStolen SSTooOldError
-------- ---------- ---------- -------- -------- ------------- -------------
16:07 252 15 1511 25 2 0
16:00 752 16 1467 150 0 0
15:50 873 21 1954 45 4 0
15:40 1187 45 3210 633 20 1
15:30 1120 28 2498 1202 5 0
15:20 882 22 2002 55 0 0
在统计项收集过程中,undo消耗最高发生在15:30-15:40这个时间段。10分钟内有1187个undo块被占用(基本上每秒钟2个块)。同时,最高事务并发也是在相同的时间段,45个事务被并发执行。执行的最长查询(1202秒)是在15:20-15:30之间,需要注意的是查询实际上是15:00-15:10段即开始并直到15:20这个时间段。

select END_TIME, UNDOBLKS,TXNCOUNT,MAXCONCURRENCY,MAXQUERYLEN,EXPSTEALCNT,SSOLDERRCNT from v$undostat;
ND_TIME UNDOBLKS TXNCOUNT MAXCONCURRENCY MAXQUERYLEN EXPSTEALCNT SSOLDERRCNT
------------------- ---------- ---------- -------------- ----------- ----------- -----------
2014-04-21 11:20:47 183 1067 3 1296 0 0
2014-04-21 11:17:14 1007 3798 5 995 0 0
2014-04-21 11:07:14 732 2565 4 2779 0 0
2014-04-21 10:57:14 1292 3973 4 2179 0 0
2014-04-21 10:47:14 1566 3952 5 1578 0 0
2014-04-21 10:37:14 1807 5487 6 1174 0 0
2014-04-21 10:27:14 2509 4493 5 376 0 0

一天上午undo消耗情况。每10分钟内有几千个个undo块被占用(如10分钟最高的有2639个undo块占用),平均3-6个事务被并发执行,执行的最长查询最长2779秒的(45分钟左右),一般平均在20分钟左右。

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】