在我们的实际的工作中,非归档模式下(注:归档模式会导致日志损坏)使用_disable_logging可以禁止日志的生成,在此条件下可以很大的提高某些特殊操作(例如批量加载或者Benchmark测试等)的性能.
禁止完成的参考示例:
首先我们需要启动两个Session,一个用来管理,一个用来测试。
1.Session 1 ,使用SYS用户连接数据库,当前_disable_logging没有设置,数据库处于正常的状态。
$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Fri Apr 14 09:30:42 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> col member for a40
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER
---------- ------- -------
1 ONLINE /opt/oracle9/oradata/testora9/redo01.log
2 ONLINE /opt/oracle9/oradata/testora9/redo02.log
3 ONLINE /opt/oracle9/oradata/testora9/redo03.log
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS
ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ----------
1 1 148 104857600 1 NO CURRENT 262708457 14-APR-06
2 1 146 104857600 1 NO INACTIVE 262662667 14-APR-06
3 1 147 104857600 1 NO ACTIVE 262675537 14-APR-06
|
2.Session 2则通过SCOTT用户连接,具体执行下面的更新:
SQL> connect scott/tiger
Connected.
SQL> update emp set sal=3000 where empno=7788;
1 row updated.
SQL> commit;
Commit complete.
|
3.在Session转储REDO日志
SQL> ALTER SYSTEM DUMP LOGFILE '
/opt/oracle9/oradata/testora9/redo01.log';
System altered.
|
4.观察跟踪文件,记录正常状态下的REDO信息
TRC文件太大,就不贴出来了
5.禁用日志生成的,并且切换日志
SQL> alter system set "_disable_logging"=true;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------
1 1 148 104857600 1 NO ACTIVE 262708457 14-APR-06
2 1 149 104857600 1 NO CURRENT 262708606 14-APR-06
3 1 147 104857600 1 NO INACTIVE 262675537 14-APR-06
|
6.SCOTT用户再更新
SQL> show parameter disable
NAME TYPE VALUE
------------------------------------
_disable_logging boolean TRUE
SQL> update emp set sal=4000 where empno=7788;
1 row updated.
SQL> commit;
Commit complete.
|
7.转储日志
SQL> ALTER SYSTEM DUMP LOGFILE '
/opt/oracle9/oradata/testora9/redo02.log';
System altered.
|
8.记录此时REDO信息
DUMP OF REDO FROM FILE '/opt/oracle9/oradata/testora9/redo02.log'
Opcodes *.*
DBA's: (file # 0, block # 0) thru (file # 65534, block # 4194303)
RBA's: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCN's scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
FILE HEADER:
Software vsn=153092096=0x9200000, Compatibility Vsn=153092096=0x9200000
Db ID=1628068176=0x610a5950, Db Name='TESTORA9'
Activation ID=1628067152=0x610a5550
Control Seq=1163=0x48b, File size=204800=0x32000
File Number=2, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000149, SCN 0x00000fa89d7e-0xffffffffffff"
thread: 1 nab: 0xffffffff seq: 0x00000095 hws: 0x1 eot: 1 dis: 0
reset logs count: 0x1f435110 scn: 0x0000.00000001
Low scn: 0x0000.0fa89d7e 04/14/2006 09:33:43
Next scn: 0xffff.ffffffff 01/01/1988 00:00:00
Enabled scn: 0x0000.00000001 04/26/2004 15:56:10
Thread closed scn: 0x0000.0fa89d7e 04/14/2006 09:33:43
Log format vsn: 0x8000000 Disk cksum: 0xcac7 Calc cksum: 0xcac7
Terminal Recovery Stamp scn: 0x0000.00000000 01/01/1988 00:00:00
Most recent redo scn: 0x0000.00000000
Largest LWN: 0 blocks
End-of-redo stream : No
Unprotected mode
Miscellaneous flags: 0x0
END OF REDO DUMP
|
至此已经没有REDO的生成.数据库目前仅仅记录少量的必要信息。