2017. 4. 3. 16:00
테이블 재생성 또는 대량 데이터 INSERT 시 REDO LOG 발생 여부에 대한 내용
단순히 NOLOGGING 모드이면 로그가 안찬다고 생각했는데
착각하고 있었던 부분이네요.
출처: http://ukja.tistory.com/333 [오라클 성능 문제에 대한 통찰 - 조동욱]
출처: http://ukja.tistory.com/333 [오라클 성능 문제에 대한 통찰 - 조동욱]
출처: http://ukja.tistory.com/333 [오라클 성능 문제에 대한 통찰 - 조동욱]
출처: http://ukja.tistory.com/333 [오라클 성능 문제에 대한 통찰 - 조동욱]
의외로 많은 분들이 아직도 Direct Path Insert(INSERT /*+ APPEND */ ... 포함)와 Redo 생성량간의 관계에 대해서 헷갈려하시는 것 같습니다.
Direct Path Insert에서 Redo 생성량에 영향을 주는 기본적인 요소는 다음과 같습니다.
- 데이터베이스가 ARCHIVELOG 모드인가, NOARCHIVE LOG 모드인가?
- 테이블이 LOGGING 모드인가, NOLOGGING 모드인가?
- 테이블에 인덱스가 존재하는가?
set echo on
set pages 10000
set lines 200
set timing off
set trimspool on
set serveroutput off
drop table t_log_no_idx purge;
drop table t_log_with_idx purge;
drop table t_nolog_no_idx purge;
drop table t_nolog_with_idx purge;
create table t_log_no_idx (c1 char(100)) logging;
create table t_log_with_idx (c1 char(100)) logging;
create table t_nolog_no_idx (c1 char(100)) nologging;
create table t_nolog_with_idx (c1 char(100)) nologging;
create index t_log_with_idx_n1 on t_log_with_idx(c1) ;
create index t_nolog_with_idx_n1 on t_nolog_with_idx(c1) ;
----------------------------------------------
-- case 1: noarchive log mode + no_index
select name, log_mode from v$database; -- NOARCHIVELOG
truncate table t_log_no_idx;
truncate table t_log_with_idx;
truncate table t_nolog_no_idx;
truncate table t_nolog_with_idx;
exec tpack.begin_session_snapshot;
insert into t_log_no_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
insert /*+ append */ into t_log_no_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
insert /*+ append */ into t_nolog_no_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
col type format a6
col item format a30
col deltas format a30
select type, item, deltas
from table(tpack.session_snapshot_report)
where type = 'STAT' and item in ('redo size', 'redo entries')
;
----------------------------------------------
-- case 2: noarchive log mode + with_index
select name, log_mode from v$database;
truncate table t_log_no_idx;
truncate table t_log_with_idx;
truncate table t_nolog_no_idx;
truncate table t_nolog_with_idx;
exec tpack.begin_session_snapshot;
insert into t_log_with_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
insert /*+ append */ into t_log_with_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
insert /*+ append */ into t_nolog_with_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
commit;
col type format a6
col item format a30
col deltas format a30
select type, item, deltas
from table(tpack.session_snapshot_report)
where type = 'STAT' and item in ('redo size', 'redo entries')
;
-----------------------------------------------
-- alter database to archive log mode
connect sys/password as sysdba
shutdown immediate
startup mount
alter database archivelog;
alter database open;
connect user/password
----------------------------------------------
-- case 3: archive log mode + no_index
select name, log_mode from v$database; -- ARCHIVELOG
truncate table t_log_no_idx;
truncate table t_log_with_idx;
truncate table t_nolog_no_idx;
truncate table t_nolog_with_idx;
exec tpack.begin_session_snapshot;
insert into t_log_no_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
insert /*+ append */ into t_log_no_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
insert /*+ append */ into t_nolog_no_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
col type format a6
col item format a30
col deltas format a30
select type, item, deltas
from table(tpack.session_snapshot_report)
where type = 'STAT' and item in ('redo size', 'redo entries')
;
----------------------------------------------
-- case 4: archive log mode + with_index
select name, log_mode from v$database;
truncate table t_log_no_idx;
truncate table t_log_with_idx;
truncate table t_nolog_no_idx;
truncate table t_nolog_with_idx;
exec tpack.begin_session_snapshot;
insert into t_log_with_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
insert /*+ append */ into t_log_with_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
insert /*+ append */ into t_nolog_with_idx select 'x' from dual connect by level <= 100000;
exec tpack.add_session_snapshot;
commit;
col type format a6
col item format a30
col deltas format a30
select type, item, deltas
from table(tpack.session_snapshot_report)
where type = 'STAT' and item in ('redo size', 'redo entries')
;
Redo Size의 측정 결과를 정리해보면 아래 표와 같습니다.
간단하게 정리해보면 다음과 같네요.
이 외에 Direct Path Insert에서 헷갈려하시는 내용들에는 다음과 같은 것들이 있습니다.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Oracle > AdminⅠ,Ⅱ' 카테고리의 다른 글
| INSERT /*+ APPEND */ ... VALUES ... (0) | 2017.04.03 |
|---|---|
| 통계정보갱신 / 테이블 DML 변경량 확인(DBA_TAB_MODIFICATIONS) (0) | 2017.03.27 |
| [ORACLE] Materialized View (MView) (0) | 2012.06.21 |
| Automatic Undo Retention 개요 (0) | 2011.08.13 |
| Diagnostic file ( Alert Log File & Trace File ) (0) | 2011.08.13 |