database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
ㆍOracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
Oracle Tutorials 17302 게시물 읽기
 News | Q&A | Columns | Tutorials | Devel | Files | Links
No. 17302
Direct load 또는 parallel insert 의 사용방법
작성자
정재익(xlib)
작성일
2004-02-11 19:43
조회수
12,874

DIRECT-LOAD 또는 PARALLEL INSERT의 사용방법(ORACLE8)
====================================================


Purpose
-------
Oracle8부터 가능한 Direct-Load Insert 방법에 대해 알아보자.


Explanation
-----------

 Direct-Load Insert 는 SGA의 buffer cache를 거치지 않고 직접
Oracle data를 구성하고 입력하는 방법이다.  이 기능은 SQL*Loader의
Direct load와 비슷한 기능이다.  이 방법은 undo entry를 생성하지
않으므로 기본 insert보다 속도가 빠르다.
 Direct-Load insert는 serial과 parallel mode를 둘 다 사용할 수 있다.


 1. Serial, Parallel Insert

  Direct-Load Insert는 partitioned와 non-partitioned table에 대해
사용할 수 있으며, 이 명령문 직후에는 반드시 commit이나 rollback이
필요하다.

  (1) Serial Direct-Load Insert - data는 해당 segment의 HWM(high
    water mark) 다음에 입력되며 commit이 실행되면 hwm이 바뀌면서
    data를 볼 수 있게 된다.

  (2) Parallel Direct-Load Insert into a nonpartitioned table
    - 각 parallel server process는 새로운 temporary segment를
    할당하고 데이타를 입력한 후에 commit이 실행되면 parallel
    coordinator가 모든 temporary segment를 기존의 segment와 합친다.

  (3) Parallel Direct-Load Insert into a partitioned table
    - 각 partition마다 하나의 parallel server process를 할당받아서
    hwm다음에 data를 입력하고 commmit이 일어나면 hwm이 바뀌게 된다.

 2. Direct-Load Insert의 사용방법

  Serial Direct-Load Insert는 APPEND hint를 통해 사용할 수 있다.
Parallel Direct-Load Insert는 APPEND 없이 PARALLEL hint만으로도
사용할 수 있다.  즉 Insert 시에 PARALLEL을 지정하면 무조건 Direct-Load로
작동하게 된다.

  [예제1] APPEND hint의 사용 
  
   SQL> insert /*+ APPEND */ into emp select * from t_emp;
   SQL> commit;
   (direct insert후에 바로 select를 하기 전에 먼저 commit;을 해야
    data를 확인할 수 있다.)

  [예제2] PARALLEL hint의 사용

   SQL> alter session enable parallel dml;
   SQL> insert /*+ PARALLEL(emp,10) */ into emp
           select /*+ PARALLEL(t_emp,10) */ * from t_emp;
   SQL> commit;

 위와 같이 Direct-Load Insert는 대량의 데이타를 한꺼번에 입력하는
 경우에 사용하는 것이 좋으므로 일반 insert into .. values 구문에서의
 사용은 지양된다. 

 3. Logging mode의 사용

  Direct-Load Insert 방법은 Logging과 no-Logging mode를 둘 다 사용할
수 있다. no-logging mode로 하면 추가된 extent에 대한 정보 등 최소한의
data dictionary의 변경 사항만이 redo log에 적용된다.
  그러나, 입력되는 data에 대한 정보는 발생하지 않으므로 속도는 훨씬 빨라진다.
no-logging mode는 table, index, tablespace 등에 지정할 수 있다.

   SQL> alter table emp nologging;
   SQL> alter session enable parallel dml;
   SQL> insert /*+ PARALLEL(emp,10) */ into emp
        select /*+ PARALLEL(t_emp,10) */ * from t_emp;
   SQL> commit;

 4. Space에 대한 고려사항

  Direct-Load Insert는 기존의 segment 영역에 있는 입력 가능한 공간을
무시하고 Insert하므로 기존의 Insert보다 더 많은 space가 필요하다. 
nonpartitioned table에 parallel insert를 할 경우에는 기존의 extent 영역에
있는 hwm 다음의 free space도 무시하고 새로운 segment를 생성하므로 insert하기
전에 이러한 추가적인 space를 고려해 두어야 한다.
  nonparititoned table에 parallel insert 시에는 지정한 parallel server
process의 수만큼 새로운 extent를 생성하는데, 그 크기는 table에 지정한
next + next*pctincrease를 고려하여 만든다. 그러므로 이 작업을 하기 전에는
next와 pctincrease를 적합한 크기로 바꾸어 줄 필요가 있다.

[Top]
No.
제목
작성자
작성일
조회
17305PARALLEL 감가 상각 PROCESS 설정 PROFILE
정재익
2004-02-11
5606
17304V8I) PARALLEL QUERY & PARALLEL DDL 사용 방법
정재익
2004-02-11
8234
17303INVENTORY TRANSACTION WORKER가 PARALLEL로 실행되지 않는 문제
정재익
2004-02-11
5336
17302Direct load 또는 parallel insert 의 사용방법
정재익
2004-02-11
12874
17301Parallel load 기능의 활용 예제
정재익
2004-02-11
7541
17300Parallel 인덱스 사용시 주의사항
정재익
2004-02-11
7695
17299PARALLEL DML 사용 방법
정재익
2004-02-11
11532
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.018초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다