现在的位置: 首页 > 综合 > 正文

关于redo(二)插入更新数据时的效率比较

2012年09月07日 ⁄ 综合 ⁄ 共 1534字 ⁄ 字号 评论关闭

     继续昨天的问题。我曾经面对一个工作,要把一张很大的表中,3个月前的数据删掉,转储到历史表中。这将是一个很大的工程,需要在一周内完成,而且只能在夜里进行工作。这就需要考虑到性能问题了,考虑到网上很多人说nologging会很快,我就做个试验,比较一下效率。

     实验环境:windows7 x64。oracle11g,11.2.0.1.0。归档模式,实验表:test1(create table test1 as select * from dba_objects;)。

     实验步骤:

实验之前记录的 redo size:35580568
insert的比较:
insert into test1 (select * from dba_objects);
commit; 

 
直接插入,redo size:49178876 产生的redo size:13598308
nologging插入,redo size:65167892 产生的redo size:15989016
append插入,redo size:78455764 产生的redo size:13287872

更改表为nologging,记录当前的redo size:78626484
直接插入,redo size:92136040 产生的redo size:13509556
append插入,redo size:99624700 产生的redo size:7488660

update的比较
update test1 set object_id = XXXX;
commit;


记录redo size: 107764388
直接更新,redo size:212615144 产生的redo size:104850756
nologging更新,redo size:319452512 产生的redo size:106837368
append更新,redo size:425422288 产生的redo size:105969776

更改表为nologging,redo size:621576604
直接更新,redo size: 726667444 产生的redo size:105090840
append更新,redo size:827687192 产生的redo size:101019748

     综上,可以看到联合使用nologging和append可以很有效的提高insert的效率,但是对于update就不是这么灵光了。
     查询oracle11gR2的官方帮助文档中关于append的部分,发现如下:
Conventional INSERT is the default in serial mode. In serial mode, direct path can be used only if you include the APPEND hint.
Direct-path INSERT is the default in parallel mode. In parallel mode, conventional insert can be used only if you specify the NOAPPEND hint.
In direct-path INSERT, data is appended to the end of the table, rather than using existing space currently allocated to the table. As a result, direct-path INSERT can be considerably faster than conventional INSERT.
     由上述说明可以看出,append只是对insert起作用,直接将数据插入表的表尾,而不是去插入表中空闲的区域。但是这样提升效率我却有点不安,是不是会有些连带的问题现在还没有展现出来。接下来我会关于这个继续研究。

抱歉!评论已关闭.