기술 정보
home
채널 소개
home

Create index online 동작 방법

문서 유형
기술 정보
분야
튜닝
키워드
Create index
Create index online
1 more property

개요

인덱스를 생성(Create index)하는 동안 해당 테이블에 DML을 수행할 수 있는 online 옵션에 대해 설명합니다. ( index 생성이 종료되기 전까지는 offline 상태로 모든 DML이 가능합니다. )

방법

Create index online 수행 예제

online 중 index 생성할 경우
<session 1> SQL> create table a (a number); Table created. SQL> insert into a select level from dual connect by level <= 100000; 100000 rows created. SQL> commit; Commit complete. SQL> insert into a values (100001); 1 row created. <session 2> SQL> create index idx_a on a (a); create index idx_a on a (a) * ERROR at line 1: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired <-- error 발생
SQL
복사
online 옵션으로 index 생성할 경우
<session 1> SQL> create table a (a number); Table 'A' created. SQL> insert into a select level from dual connect by level <= 100000; 100000 rows inserted. SQL> commit; Commit completed. SQL> select count(*) from a; COUNT(*) --------- 100000 1 row selected. SQL> insert into a values (100001); 1 row inserted. <session 2> SQL> create index idx_a on a (a) online; <session 1> SQL> commit; Commit completed. <session 2> Index 'IDX_A' created. <-- index 생성됨SQL> set autot on SQL> select /*+ index(a) / count() from a where a < 1000000; COUNT(*) --------- 100001 1 row selected. SQL ID: 266 Plan Hash Value: 1910050088 Execution Plan -------------------------------------------------------------------------------- 1 COLUMN PROJECTION (Cost:225, %CPU:0, Rows:1) 2 SORT AGGR (Cost:225, %CPU:0, Rows:1) 3 INDEX (RANGE SCAN): IDX_A (Cost:225, %CPU:0, Rows:126912) Predicate Information -------------------------------------------------------------------------------- 3 - access: ("A"."A" < 1000000) (1.000)
SQL
복사
참고
create index online 중 statement cancel 시 index가 생성은 되지만, disable 상태로 생성됩니다.
alter index rebuild 혹은 drop/create 로 재생성 필요합니다.