對錶進行dml操作時影響產生日誌量的幾個因素
歸檔模式
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u02/archive_log
Oldest online log sequence 29
Next log sequence to archive 31
Current log sequence 31
1.創建測試表hat_objects
SQL> create table hat_objects as select * from all_objects where 1<>1;
Table created
2.打開執行計劃
SQL> set autotrace traceonly statistics;
3.插入數據
SQL> insert into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
5877 recursive calls
5779 db block gets
80216 consistent gets
0 physical reads
4684152 redo size
675 bytes sent via SQL*Net to client
585 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
40685 rows processed
4.使用提示插入數據
SQL> insert /*+ append */ into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
5278 recursive calls
774 db block gets
79281 consistent gets
0 physical reads
4692132 redo size
660 bytes sent via SQL*Net to client
599 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
40685 rows processed
注:直接insert與使用append提示insert產生的日誌大小相差無幾,未減少日誌的產生。
5.設置hat_objects爲nologging模式
SQL> alter table hat_objects nologging;
Table altered.
6.插入數據
SQL> insert into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
5232 recursive calls
5104 db block gets
80000 consistent gets
0 physical reads
4630652 redo size
676 bytes sent via SQL*Net to client
585 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
40685 rows processed
7.使用提示插入數據
SQL> insert /*+ append */ into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
5278 recursive calls
776 db block gets
79281 consistent gets
0 physical reads
19648 redo size
662 bytes sent via SQL*Net to client
599 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
40685 rows processed
注:當表hat_objects設置爲nologging模式後,使用append提示後insert,日誌的產生量明顯比直接
insert少。
非歸檔模式
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u02/archive_log
Oldest online log sequence 29
Current log sequence 31
1.創建測試表
SQL> create table hat_objects as select * from all_objects where 1<>1;
Table created.
2.插入數據
SQL> insert into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
6773 recursive calls
6276 db block gets
80723 consistent gets
2 physical reads
4737072 redo size
680 bytes sent via SQL*Net to client
585 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
21 sorts (memory)
0 sorts (disk)
40685 rows processed
3.使用提示插入數據
SQL> insert /*+ append */ into hat_objects select * from all_objects;
40684 rows created.
Statistics
----------------------------------------------------------
5278 recursive calls
762 db block gets
79281 consistent gets
0 physical reads
18332 redo size
664 bytes sent via SQL*Net to client
599 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
40684 rows processed
注:直接insert與使用append提示insert產生的日誌大小相差很大,減少了日誌的產生。
4.設置表hat_objects爲nologging模式
SQL> alter table hat_objects nologging;
Table altered.
5.插入數據
SQL> insert into hat_objects select * from all_objects;
40684 rows created.
Statistics
----------------------------------------------------------
5454 recursive calls
5104 db block gets
80005 consistent gets
0 physical reads
4630688 redo size
680 bytes sent via SQL*Net to client
585 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
40684 rows processed
6.使用提示插入數據
SQL> insert/*+ append */ into hat_objects select * from all_objects;
40684 rows created.
Statistics
----------------------------------------------------------
5278 recursive calls
782 db block gets
79281 consistent gets
0 physical reads
19648 redo size
664 bytes sent via SQL*Net to client
598 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
40684 rows processed
注:當表hat_objects設置爲nologging模式後,使用append提示後insert,日誌量比直接insert少,
但與表hat_objects設置爲logging模式相比較,同樣使用append提示產生的日誌量差不多。
總結:在歸檔模式下,只有將表設置爲nologging並且使用append提示才能大量減少日誌的產生;在非
歸檔模式下,無論是否將表設置爲nologging,只要使用append提示都會大量減少日誌的產生。
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u02/archive_log
Oldest online log sequence 29
Next log sequence to archive 31
Current log sequence 31
1.創建測試表hat_objects
SQL> create table hat_objects as select * from all_objects where 1<>1;
Table created
2.打開執行計劃
SQL> set autotrace traceonly statistics;
3.插入數據
SQL> insert into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
5877 recursive calls
5779 db block gets
80216 consistent gets
0 physical reads
4684152 redo size
675 bytes sent via SQL*Net to client
585 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
40685 rows processed
4.使用提示插入數據
SQL> insert /*+ append */ into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
5278 recursive calls
774 db block gets
79281 consistent gets
0 physical reads
4692132 redo size
660 bytes sent via SQL*Net to client
599 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
40685 rows processed
注:直接insert與使用append提示insert產生的日誌大小相差無幾,未減少日誌的產生。
5.設置hat_objects爲nologging模式
SQL> alter table hat_objects nologging;
Table altered.
6.插入數據
SQL> insert into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
5232 recursive calls
5104 db block gets
80000 consistent gets
0 physical reads
4630652 redo size
676 bytes sent via SQL*Net to client
585 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
40685 rows processed
7.使用提示插入數據
SQL> insert /*+ append */ into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
5278 recursive calls
776 db block gets
79281 consistent gets
0 physical reads
19648 redo size
662 bytes sent via SQL*Net to client
599 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
40685 rows processed
注:當表hat_objects設置爲nologging模式後,使用append提示後insert,日誌的產生量明顯比直接
insert少。
非歸檔模式
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u02/archive_log
Oldest online log sequence 29
Current log sequence 31
1.創建測試表
SQL> create table hat_objects as select * from all_objects where 1<>1;
Table created.
2.插入數據
SQL> insert into hat_objects select * from all_objects;
40685 rows created.
Statistics
----------------------------------------------------------
6773 recursive calls
6276 db block gets
80723 consistent gets
2 physical reads
4737072 redo size
680 bytes sent via SQL*Net to client
585 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
21 sorts (memory)
0 sorts (disk)
40685 rows processed
3.使用提示插入數據
SQL> insert /*+ append */ into hat_objects select * from all_objects;
40684 rows created.
Statistics
----------------------------------------------------------
5278 recursive calls
762 db block gets
79281 consistent gets
0 physical reads
18332 redo size
664 bytes sent via SQL*Net to client
599 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
40684 rows processed
注:直接insert與使用append提示insert產生的日誌大小相差很大,減少了日誌的產生。
4.設置表hat_objects爲nologging模式
SQL> alter table hat_objects nologging;
Table altered.
5.插入數據
SQL> insert into hat_objects select * from all_objects;
40684 rows created.
Statistics
----------------------------------------------------------
5454 recursive calls
5104 db block gets
80005 consistent gets
0 physical reads
4630688 redo size
680 bytes sent via SQL*Net to client
585 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
40684 rows processed
6.使用提示插入數據
SQL> insert/*+ append */ into hat_objects select * from all_objects;
40684 rows created.
Statistics
----------------------------------------------------------
5278 recursive calls
782 db block gets
79281 consistent gets
0 physical reads
19648 redo size
664 bytes sent via SQL*Net to client
598 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
40684 rows processed
注:當表hat_objects設置爲nologging模式後,使用append提示後insert,日誌量比直接insert少,
但與表hat_objects設置爲logging模式相比較,同樣使用append提示產生的日誌量差不多。
總結:在歸檔模式下,只有將表設置爲nologging並且使用append提示才能大量減少日誌的產生;在非
歸檔模式下,無論是否將表設置爲nologging,只要使用append提示都會大量減少日誌的產生。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.