Oracle一个表上存在物化视图日志和基于物化视图日志快速刷新的物化视图,如果对这个表进行DML操作,则Redolog产生量将翻数倍,并且执行时间加长,影响并发操作。
下面主要通过在Redolog产生量和执行时间上做对比:
DB Version:12.1.0.2.0
OS:CentOS 6.6
[oracle@ct6603 ~]$ sqlplus system/system
SQL*Plus: Release 12.1.0.2.0 Production on Sat Nov 5 17:11:31 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Sat Nov 05 2016 17:11:12 +08:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
#建测试表
SQL> create table tb_rowid tablespace users as select * from dba_objects;
Table created.
#记录时间
SQL> set timing on
#设定自动提交
SQL> set autocommit on
#跟踪统计信息
SQL> set autotrace on stat
#表tb_rowid上无物化视图日志
#插入9999笔记录,Redolog产生量1249324,耗时00:00:00.21
SQL> insert into tb_rowid select * from tb_rowid where rownum insert into tb_rowid select * from tb_rowid where rownum delete tb_rowid where rownum delete tb_rowid where rownum update tb_rowid set object_id=1 where rownum update tb_rowid set object_id=2 where rownum update tb_rowid set object_id=2 where rownum create materialized view log on tb_rowid with rowid including new values;
Materialized view log created.
Elapsed: 00:00:00.34
#插入9999笔记录,Redolog产生量10905808,耗时00:00:03.73
SQL> insert into tb_rowid select * from tb_rowid where rownum insert into tb_rowid select * from tb_rowid where rownum delete tb_rowid where rownum delete tb_rowid where rownum update tb_rowid set object_id=2 where rownum update tb_rowid set object_id=2 where rownum create materialized view mv_tb_rowid tablespace users refresh fast on commit with rowid as select * from tb_rowid;
Materialized view created.
Elapsed: 00:00:29.52
#插入9999笔记录,Redolog产生量20177192,耗时00:00:08.98
SQL> insert into tb_rowid select * from tb_rowid where rownum insert into tb_rowid select * from tb_rowid where rownum delete tb_rowid where rownum delete tb_rowid where rownum update tb_rowid set object_id=2 where rownum update tb_rowid set object_id=2 where rownum