TUNE V$UNDOSTAT

在一个18摸AIX上跑的一台11g的库,检查的时候发现视图V$UNDOSTAT的数据很诡异,第1条的记录时间段竟然一直没有被切割过,开始时间是2011-12-26 09:52:08结束时间是2013-05-14 15:20:34,当然归档表也没记录。
正常情况下该视图应该被没10分钟的数据给填充满,一直持续4天,也就是 6*24*4=576 条记录,之后会重用这个表;相关的历史记录会归档到DBA_HIST_UNDOSTAT中去。
记录按照时间从近到远的倒序插入,其中第1条记录是最后一次收集的结束点到当前的时间间隔,你可以看到END_TIME是不断在刷新的。

来看下正常情况的是怎么样的。

[oracle@LINUXDB ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' 
[oracle@LINUXDB ~]$ sqlplus "/as sysdba"                          

SQL*Plus: Release 11.2.0.3.0 Production on Tue May 14 15:19:58 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select begin_time,end_time from v$undostat;

BEGIN_TIME          END_TIME
------------------- -------------------
2013-05-14 15:16:04 2013-05-14 15:20:00
2013-05-14 15:06:04 2013-05-14 15:16:04
2013-05-14 14:56:04 2013-05-14 15:06:04
2013-05-14 14:46:04 2013-05-14 14:56:04
2013-05-14 14:36:04 2013-05-14 14:46:04
2013-05-14 14:26:04 2013-05-14 14:36:04
2013-05-14 14:16:04 2013-05-14 14:26:04
2013-05-14 14:06:04 2013-05-14 14:16:04
2013-05-14 13:56:04 2013-05-14 14:06:04
2013-05-14 13:46:04 2013-05-14 13:56:04
2013-05-14 13:36:04 2013-05-14 13:46:04

BEGIN_TIME          END_TIME
------------------- -------------------
2013-05-14 13:26:04 2013-05-14 13:36:04
2013-05-14 13:16:04 2013-05-14 13:26:04
2013-05-14 13:06:04 2013-05-14 13:16:04
2013-05-14 12:56:04 2013-05-14 13:06:04
2013-05-14 12:46:04 2013-05-14 12:56:04
2013-05-14 12:36:04 2013-05-14 12:46:04
2013-05-14 12:26:04 2013-05-14 12:36:04
2013-05-14 12:16:04 2013-05-14 12:26:04
2013-05-14 12:06:04 2013-05-14 12:16:04
2013-05-14 11:56:04 2013-05-14 12:06:04
2013-05-14 11:46:04 2013-05-14 11:56:04

22 rows selected.

SQL> select begin_time,end_time from dba_hist_undostat;

BEGIN_TIME          END_TIME
------------------- -------------------
2013-05-14 11:46:04 2013-05-14 11:56:04
2013-05-14 12:56:04 2013-05-14 13:06:04
2013-05-14 13:06:04 2013-05-14 13:16:04
2013-05-14 13:16:04 2013-05-14 13:26:04
2013-05-14 13:26:04 2013-05-14 13:36:04
2013-05-14 13:36:04 2013-05-14 13:46:04
2013-05-14 13:46:04 2013-05-14 13:56:04
2013-05-14 11:56:04 2013-05-14 12:06:04
2013-05-14 12:06:04 2013-05-14 12:16:04
2013-05-14 12:16:04 2013-05-14 12:26:04
2013-05-14 12:26:04 2013-05-14 12:36:04

BEGIN_TIME          END_TIME
------------------- -------------------
2013-05-14 12:36:04 2013-05-14 12:46:04
2013-05-14 12:46:04 2013-05-14 12:56:04
2013-05-14 13:56:04 2013-05-14 14:06:04
2013-05-14 14:06:04 2013-05-14 14:16:04
2013-05-14 14:16:04 2013-05-14 14:26:04
2013-05-14 14:26:04 2013-05-14 14:36:04
2013-05-14 14:36:04 2013-05-14 14:46:04
2013-05-14 14:46:04 2013-05-14 14:56:04

19 rows selected.

现在来看看没有切割的情况:

AIX Version 6
Copyright IBM Corporation, 1982, 2011.
login: oracle
oracle's Password: 
*******************************************************************************
*                                                                             *
*                                                                             *
*  Welcome to AIX Version 6.1!                                                *
*                                                                             *
*                                                                             *
*  Please see the README file in /usr/lpp/bos for information pertinent to    *
*  this release of the AIX Operating System.                                  *
*                                                                             *
*                                                                             *
*******************************************************************************
Last unsuccessful login: Fri May  3 21:52:33 GMT+08:00 2013 on /dev/pts/6 from 10.46.154.32
Last login: Tue May 14 15:11:11 GMT+08:00 2013 on /dev/pts/6 from 10.46.160.207

AIXDB:/oracle$ export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
AIXDB:/oracle$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production on Tue May 14 15:20:12 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select begin_time,end_time from v$undostat where rownum<=5;

BEGIN_TIME          END_TIME
------------------- -------------------
2011-12-26 09:52:08 2013-05-14 15:20:34
2011-12-26 09:42:08 2011-12-26 09:52:08
2011-12-26 09:32:08 2011-12-26 09:42:08
2011-12-26 09:22:08 2011-12-26 09:32:08
2011-12-26 09:12:08 2011-12-26 09:22:08

SQL>  select begin_time,end_time from dba_hist_undostat;

no rows selected

这个确实不太正常,这样一条横跨所有时间段的统计数据和没有统计数据一样,不具备可衡量和检测性;但是由于是生产环境,可能出于什么原因取消了信息的统计暂且不管,我们来看看到底是怎么样的设置才会导致这样的效果。
接着发现个不一样的现象,在Linux的11203和AIX的11202当中有个参数_undo_autotune默认不一样的取值:
SQL> show parameter undo

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTBS1
SQL> show parameter undo

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
_undo_autotune                       boolean     FALSE
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTBS1

这点着实有点疑惑,个人猜测由于版本不一样,况且平台还不一样,所以不一致是有可能的,这样就可以解释为什么我观察到的V$UNDOSTAT和DBA_HIST_UNDOSTAT的数据差异的情况了:
当_undo_autotune =FALSE的时候,就不会自动将统计信息分割存放和归档,如果要启用这个特性需要设置_undo_autotune =TRUE。

设置_undo_autotune =FALSE 时候:
SQL> alter system set "_undo_autotune"=FALSE scope=both;

System altered.

SQL> startup force;
ORACLE instance started.

Total System Global Area 2.0176E+10 bytes
Fixed Size                  2237048 bytes
Variable Size            2483031432 bytes
Database Buffers         1.7650E+10 bytes
Redo Buffers               41488384 bytes
Database mounted.
Database opened.
SQL> select sysdate from dual;

SYSDATE
-------------------
2013-05-14 16:23:59

SQL> select begin_time,end_time from v$undostat;

BEGIN_TIME          END_TIME
------------------- -------------------
2013-05-14 16:22:35 2013-05-14 16:24:00
SQL> select begin_time,end_time from v$undostat;

BEGIN_TIME          END_TIME
------------------- -------------------
2013-05-14 16:22:35 2013-05-14 16:54:27
可以看到都过了半个小时了还没有插入新的纪录。

设置_undo_autotune =TRUE 时候:
SQL> alter system set "_undo_autotune"=TRUE scope=both;

System altered.
SQL> select begin_time,end_time from v$undostat;

BEGIN_TIME          END_TIME
------------------- -------------------
2013-05-14 17:02:35 2013-05-14 17:05:37
2013-05-14 16:52:35 2013-05-14 17:02:35
2013-05-14 16:32:35 2013-05-14 16:52:35
2013-05-14 16:22:35 2013-05-14 16:32:35

这样就由恢复自动收集的状态了。
-EOF-

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值