본문 바로가기

닷컴's_열공/Database

[oracle] Nologging 과 insert apend

- 아래 실험 결과를 보시면, insert /*+ append */ into 의 문법이 맞고 insert into /*+ append */ 는 틀립니다.

이번에도 같은 이유로 redolog가 generation 된듯합니다.

- append후에 nologging 옵션이 붙는 것도 잘못된 문법으로 보입니다. 아래처럼

I NSERT /*+ APPEND NOLOGGING PARALLEL */


병렬 insert를 할 경우에 Parallel 과 함께 사용됩니다.

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production

SQL> create table test as select * from all_objects where 1 = 2;

테이블이 생성되었습니다.

SQL> set autot trace stat;
SQL> insert into test select * from all_objects;

28737 개의 행이 만들어졌습니다.
Statistics
----------------------------------------------------------
385 recursive calls
4743 db block gets
128765 consistent gets
0 physical reads
3446688 redo size
630 bytes sent via SQL*Net to client
542 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
28737 rows processed

SQL> insert into /*+ append */ test select * from all_objects;(잘못된 문법을 사용한 경우)
28737 개의 행이 만들어졌습니다.


Statistics
----------------------------------------------------------
83 recursive calls
4488 db block gets
128677 consistent gets
0 physical reads
3419760 redo size( 옵션없이 사용한 것과 거의 동일한 결과가 나옴)

630 bytes sent via SQL*Net to client
556 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
28737 rows processed

SQL> insert /*+ append */ into test select * from all_objects;(바른옵션 사용시)


28737 개의 행이 만들어졌습니다.


Statistics
----------------------------------------------------------
70 recursive calls
39 db block gets
127823 consistent gets
0 physical reads
4740 redo size

614 bytes sent via SQL*Net to client
556 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
28737 rows processed

SQL> commit;

커밋이 완료되었습니다.

SQL> insert into /*+ append nologging test */
2 nologging test select * from all_objects;
nologging test select * from all_objects
*
2행에 오류:
ORA-00942: 테이블 또는 뷰가 존재하지 않습니다

 

그냥 참조하세요...


export 파일을 이용하여 import 할때 table이나 인덱스는 기본적으로 nologging 설정됩니다.

그래서인지 몰라도, MIS 시스템과 MES DB 중에 Nologging 으로 설정된 Table 들이 꽤 많더군요...


일반적인 insert 나, update , delete 문장은 테이블이나 인덱스가 nologging 이라 하더라도

redo log 에 기록을 남깁니다. 그래서 복구할 때 큰 문제는 없습니다만..


하지만 direct path 를 사용하여 insert 하는 경우 redo log 에 남기 않기 때문에

작업 후 바로 full backup 을 받아야 합니다.저희는 매일매일 백업을 받기 때문에 문제가 없지요..

그렇지 않고 Media Recovery를 하게 될 경우에 ORA-01578 ...Block Corruption 과 같은 에러가 발생할 수 있지요..


불안하시면 지금 테이블과 인덱스를 Logging 으로 바꿔주시는게 좋겠죠...

이 외에도 redo log에 logging 하지 않는 operation 들이 몇가지 더 있는데, 아래와 같습니다.

The following operations can make use of NOLOGGING mode:

direct load (SQL*Loader)
direct-load INSERT
CREATE TABLE ... AS SELECT
CREATE INDEX
ALTER TABLE ... MOVE PARTITION
ALTER TABLE ... SPLIT PARTITION
ALTER INDEX ... SPLIT PARTITION
ALTER INDEX ... REBUILD
ALTER INDEX ... REBUILD PARTITION
INSERT, UPDATE, and DELETE on LOBs in NOCACHE NOLOGGING mode stored out of line

[출처] Nologging 과 insert apend|작성자 꼰티