oracle 9i临时表产生过多redo

 今天遇到一个bug,对临时表进行insert的时候产生异常多的redo,下面模拟过程:
 
 SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production

TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production

 

--在会话1执行:
SQL> create global temporary table t1(id int) on commit preserve rows;

Table created

SQL> create global temporary table t2(id int) on commit delete rows;

Table created

SQL> create table t3(id int);

Table created

SQL> select * from v$statname where name='redo size';

STATISTIC# NAME                                                                  CLASS
---------- ---------------------------------------------------------------- ----------
       115 redo size                                                                 2


--新开一个会话2执行:

SQL> select * from v$mystat where rownum=1;

       SID STATISTIC#      VALUE
---------- ---------- ----------
        10          0          1

SQL>  insert into t1 select rownum from dual connect by rownum<500000;

499999 rows inserted


--在会话1查询产生的redo量
SQL> select * from v$sesstat where sid=10 and statistic#=115;

       SID STATISTIC#      VALUE
---------- ---------- ----------
        10        115   62249712


--再会话2往t2插入数据
SQL> insert into t2 select rownum from dual connect by rownum<500000;

499999 rows inserted


--会话1中查询此时的redo情况
SQL> select * from v$sesstat where sid=10 and statistic#=115;

       SID STATISTIC#      VALUE
---------- ---------- ----------
        10        115  124499216

       
--在会话1往普通表插入数据
SQL> insert into t3 select rownum from dual connect by rownum<500000;

499999 rows inserted

--会话1中查询此时的redo情况
SQL> select * from v$sesstat where sid=10 and statistic#=115;

       SID STATISTIC#      VALUE
---------- ---------- ----------
        10        115  132242444

       

--产生的redo比较:
       
会话级临时表:62249712
事务级临时表:62249504
普通表      :7743228

可见,无论对事务级的临时表还是会话级的临时表,都产生远比普通表多的redo,这是极不正常的。
临时表的数据对于恢复是没有任何用处的,所以,它不需要为insert的数据记录redo信息。因此,遇到上面的情况,十有八九是因为bug引起的。
查了一个metalink,确认这是一个bug:

Bug 2874489  Excessive REDO generated for INSERT as SELECT into GLOBAL TEMPORARY TABLES
 This note gives a brief overview of bug 2874489.

Using 'insert as select' to insert into a global
temporary table can generate far more redo than
the same insert into a permanent table.

Updates and deletes are not affected, only multirow inserts. 

这个 bug在9205后修正。
实际上,这个bug也影响undo的使用,对临时表的操作占用的undo远比普通表多。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/231499/viewspace-119992/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/231499/viewspace-119992/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值