2007年07月5日
測試nologging在做dml的redo log運作情況
目地:測試nologging在做dml的redo log運作情況
os: Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
oracle: 9.2.0.4.0
os: Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
oracle: 9.2.0.4.0
1、環境準備
2、(參考範例)
3、查看一下現在 tb 共用了多少空間了(我是大約快4m),快接近一個redo log 的上限了
4、測試開始(要配合alter log檔來看)
結論:
1、在archive log mode中,table是nologging只有在加了 append 才會生效
2、使用append時,這時的table是無法進行操作的,因為oracle暫時還不知hwm以上的資料為何,這時oracle只認為那是一個大資料
| 1、把redolog file設成5m,較好觀查nologging對redo log的影響 2、建立一個較小的tablespace |
2、(參考範例)
| SQL>create tablespace tb datafile '/u01/tb.dbf' size 8M| autoextend on next 4M extent management local autoallocate segment space management auto; SQL>create table test nologging tablespace tb as select * from dba_objects; |
3、查看一下現在 tb 共用了多少空間了(我是大約快4m),快接近一個redo log 的上限了
4、測試開始(要配合alter log檔來看)
| SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. (先清一下redo log,這時你看產生的archive log 檔,後面應該都很小才對) SQL> create table test nologging tablespace tb as select * from dba_objects; Table created. (以我的環境的設定來說,是不會產生redo log switch的情況發生,並且查看table 是4m) SQL> insert into test select * from dba_objects; 30818 rows created. SQL> commit; Commit complete. SQL> insert into test select * from dba_objects; 30818 rows created.(這時產生了redo log switch了,因為redo的量超過一個redo log 的大小了) SQL> commit; Commit complete. (所以得到在 db在archive log 和table是設nologging還是會產生redo log 的動作) (先清一下環境,準備做另一個測試) SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. (這時table已快11m了) (先測一下rollback會是怎樣) SQL> select count(*) from test; COUNT(*) ---------- 92454 SQL> insert /*+ append */ into test select * from dba_objects; 30818 rows created. SQL> select count(*) from test; select count(*) from test * ERROR at line 1: ORA-12838: cannot read/modify an object after modifying it in parallel SQL> rollback; Rollback complete. SQL> select count(*) from test; COUNT(*) ---------- 92454 (發生了,還沒有commit之前是無法查尋的=.=",猜想應該是append是直接寫在hwm之上,而|append是不會把dml記錄在redo log中的。) 下列來請注意alter log裏的archive 的log 訊習 SQL> insert /*+ append */ into test select * from test; 92454 rows created.(沒有switch redo log發生,注意這時 insert 的資料量已超過一個redo log檔的大小了 ) SQL> alter system switch logfile; (強迫switch,來看看會多大,我這裏才8多k) System altered. SQL> / (強迫switch,來看看會多大,我這裏才1k) System altered. SQL> / (強迫switch,來看看會多大,我這裏才2k) System altered. SQL> commit; (把上面的資料寫入) Commit complete. SQL> alter system switch logfile; (強迫switch,來看看會多大,我這裏才7百多k;由這裏就可知道nologging生效了) System altered. SQL> insert into test select * from test; (再次驗證上面的說法,直接來做 insert,不加append,這時你應該可以看到4 個switch redo log的情況發生了,並且每個archive log都是5m的) 184908 rows created. |
1、在archive log mode中,table是nologging只有在加了 append 才會生效
2、使用append時,這時的table是無法進行操作的,因為oracle暫時還不知hwm以上的資料為何,這時oracle只認為那是一個大資料
引用URL
http://cgi.blog.roodo.com/trackback/3581135