Oracle/Admin2010. 4. 27. 09:26

-- CREATE INDEX 시에 하기 쿼리로 SPACE 를 추적 가능
-- CREATE INDEX XAK1MIG_TEST2 ON MIG_TEST2 ( A2, B ) ;
-- 병렬로 생성 가능
-- CREATE INDEX XAK1MIG_TEST2 ON MIG_TEST2 ( A2, B ) PARALLEL 10 ;
-- 병렬로 인덱스 리빌드 가능
-- ALTER INDEX XAK1MIG_TEST2 REBUILD TABLESPACE USERS PARALLEL 10 ;

-- 병렬 체크
select a.sql_text
from v$sqltext a, v$session b
where a.address=b.sql_address and
a.hash_value=b.sql_hash_value and
b.sid in (select sid from v$px_session) ;

-- Sort Usage 체크
select   se.username
        ,se.sid
        ,su.extents
        ,su.blocks * to_number(rtrim(p.value)) as Space
        ,tablespace
        ,segtype
from     v$sort_usage su
        ,v$parameter  p
        ,v$session    se
where    p.name          = 'db_block_size'
and      su.session_addr = se.saddr
order by se.username, se.sid ;

 

병렬 작업 후 반드시 해당 인덱스의 DEGREE 를 1로 변경 해준다.

 

ALTER INDEX XAK_CHECK_PARALLEL PARALLEL (DEGREE 1 ) ;

 

확인은

SELECT OWNER,INDEX_NAME,TABLE_NAME, DEGREE FROM DBA_INDEXES

WHERE INDEX_NAME ='XAK_CHECK_PARALLEL';

 

병렬 쿼리 인덱스 관련 정보

2. Space 의 관리

(1) Create table .. as select, create index 작업의 저장 영역


Parallel 하게 table 이나 index를 생성하는 경우 create 명령의
storage 절의 initial 값으로 temporary segment를 생성한다.
Initial 값이 5M이고 parallel degree 를 10으로 설정하여 table을
생성하는 경우는 5M 씩 10개의 temporary segment가 만들어지면서
data를 저장한다. 그리고 Parallel coordinator 가 temporary
segment를 병합한다.


(2) Temporary segment 의 free space 관리


Data의 loading 작업이 끝난 후에 각 temporary segment에서
사용되지 않은 free space를 가진 extent가 tablespace level에서
설정한 minimum extent 값보다 크면 parallel coordinator 가
모든 temporary segment를 병합할 때 사용하지 않은 영역은 잘라낸다.
잘려진 영역은 datafile의 free space로 돌려지며 다른 object에 의해
사용될 수 있다. 그러나 연속된 영역이 아니므로 하나의 큰 segment로
합쳐질 수 없다. (external fragmentation)
위의 경우에서 free space를 가진 extent가 minimum extent 값보다
작으면 parallel coordinator 가 모든 temporary segment를 병합할 때
사용하지 않은 영역도 포함시킨다. 이 부분은 후에 data가 insert될 때
사용된다. (internal fragmentation)

'Oracle > Admin' 카테고리의 다른 글

[펌] TNS-12546: TNS:permission denied  (0) 2010.05.28
session kill 하는 SQL  (0) 2010.05.21
alert_SID.log  (0) 2010.03.24
index rebuild 작업  (0) 2010.02.25
Globalization  (0) 2010.01.11
Posted by 자수성가한 부자
Oracle/Backup & Recovery2010. 4. 17. 12:27
테스트 시나리오 :

핫백업 중에 DB가 강제 종료가 된다면 어떻게 될까?
(alter tablespace XXXX begin backup
  -> !cp /oracle/XXX.dbf /oracle_backup/XXX.dbf
    -> 강제 종료(shutdown abort))


테스트 :

0. 현재 인스턴스명과 상태 확인

SQL> select instance_name, status from v$instance;
INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN


1. 테이블 스페이스 단위 핫백업

SQL> select name from v$tablespace;
NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
USERS
EXAMPLE
TEMP

SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf

SQL> alter tablespace system begin backup;
Tablespace altered.

SQL> !cp /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/orcl_backup/system01.dbf


2. 강제 종료

SQL> shutdown abort;
ORACLE instance shut down.


3. 시작

SQL> startup;
ORACLE instance started.


4. 에러 메시지 확인

ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'


5. 문제 원인 분석

  위의 에러 메시지로 나타날 수 있는 장애의 원인이 4가지라고 한다.(metalink 문서번호 : 183367.1)

   1) 핫백업 중에 테이블 스페이스 장애 후 startup시
   2) 백업에서 데이터 파일 또는 테이블스페이스 복원 후에 startup시
   3) 데이터 파일 또는 테이블 스페이스를 온라인으로 시도할 때
   4) 불완전 복구시에 'using backup controlfile' 옵션으로 복구할 때
  
 원인은 이미 알고 있는 거지만 2)이므로 2)에 대한 해결만 이 포스트에서 하겠다.
 

6. 장애 해결

  1) mount로 startup(어차피 그냥 startup 하더라도 mount까지밖에 올라가지 않는다.)

SQL> startup mount;


  2) 핫백업 중인 데이터 파일을 찾는다.

SQL> SELECT V1.FILE#, NAME 
          FROM V$BACKUP V1, V$DATAFILE V2 
          WHERE V1.STATUS = 'ACTIVE' AND V1.FILE# = V2.FILE# ;

     FILE# NAME
---------- ----------------------------------------------------------------------------------------------------
         1 /u01/app/oracle/oradata/orcl/system01.dbf


  3) 다음의 명령을 통해 end backup을 실시한다.

SQL> alter tablespace system01 end backup;

  4) 데이터베이스를 open한다.

SQL> alter database open;


참조 : http://blog.naver.com/darkturtle?Redirect=Log&logNo=50029568769

'Oracle > Backup & Recovery' 카테고리의 다른 글

current redo log group 삭제시 복구  (0) 2010.11.24
RMAN  (0) 2010.07.09
Block Corruption  (0) 2009.12.23
restore points  (0) 2009.12.23
clone DB를 이용한 incomplete recovery 실습2 : RMAN  (0) 2009.12.22
Posted by 자수성가한 부자
Oracle/기타2010. 4. 1. 19:55
clone database를 생성하다가 이런 에러를 만났다.



데이터베이스 이름은 8자리가 안된다.

'Oracle > 기타' 카테고리의 다른 글

SQL*PLUS에서 명령 편집  (0) 2010.07.08
database의 feature의 사용유무 체크뷰  (0) 2010.05.04
오라클 30초 간격으로 동일한 값 넣는 쿼리  (1) 2010.02.24
import 성능 향상시키는 방법  (0) 2010.02.11
reorganization  (0) 2010.02.11
Posted by 자수성가한 부자
Oracle/Admin2010. 3. 24. 23:11

● 어떤 파일?
 - 오라클 인스턴스가 동작할 때 발생되는 여러 이벤트나 에러 등이 기록되는 파일로,
   데이터베이스의 관리, 백업, 복구, 튜닝에 중요한 정보를 제공.

● 어느 위치에 저장?
 - background_dump_dest에 정의된 위치

● 확인 가능한 내용은?
 - 데이터베이스 startup, shutdown 등

Starting ORACLE instance (normal)


 - 테이블스페이스 생성

create tablespace SYSAUX datafile  '/jenis/oradata/system/sysaux01.dbf'
SIZE 10240M REUSE AUTOEXTEND ON NEXT  1024K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online

 
- system parameter 중 기본값이 아닌 파라미터 값


System parameters with non-default values:
  processes                = 4000
  sessions                 = 4405
  shared_pool_size         = 1258291200
  large_pool_size          = 117440512
  java_pool_size           = 117440512
  control_files            = /jenis/oradata/system/control01.ctl, /jenis/oradata/system/control02.ctl, /jenis/oradata/system/control03.ctl
  db_block_size            = 8192
  db_cache_size            = 4194304000
  compatible               = 10.2.0.3.0
.....


 - 백그라운드 프로세스 기동내용

PMON started with pid=2, OS id=19798
PSP0 started with pid=3, OS id=19800
MMAN started with pid=4, OS id=19802
DBW0 started with pid=5, OS id=19804
DBW1 started with pid=6, OS id=19806
DBW2 started with pid=7, OS id=19808
LGWR started with pid=8, OS id=19810
CKPT started with pid=9, OS id=19812
SMON started with pid=10, OS id=19814
RECO started with pid=11, OS id=19816
CJQ0 started with pid=12, OS id=19818
MMON started with pid=13, OS id=19820


 - 로그 스위치 내용

Thu Feb 25 22:00:10 2010
Thread 1 advanced to log sequence 10 (LGWR switch)
  Current log# 1 seq# 10 mem# 0: /jenis/oradata/system/redo01_01.log
  Current log# 1 seq# 10 mem# 1: /jenis/oradata/system/redo01_02.log



 - Checkpoint 발생시간과 상태


Checkpoint not complete
  Current log# 3 seq# 54 mem# 0: /jenis/oradata/system/redo03_01.log
  Current log# 3 seq# 54 mem# 1: /jenis/oradata/system/redo03_02.log


● 특징은?
 - 데이터베이스 당 하나씩 생성
 - 하나의 파일에 계속 내용이 쌓이므로 파일이 너무 커졌을 경우 다른 곳으로 복사하고
   새로 생성할 필요가 있음.(최대크기는 max_dump_file_size에 정의되어 있음)

'Oracle > Admin' 카테고리의 다른 글

session kill 하는 SQL  (0) 2010.05.21
create index, index rebuild  (0) 2010.04.27
index rebuild 작업  (0) 2010.02.25
Globalization  (0) 2010.01.11
Security  (0) 2010.01.08
Posted by 자수성가한 부자
OS_NETWORK_Storage2010. 3. 20. 13:21

흔히 유닉스에서 스토리지 디바이스를 억세스하는 방법에 따라

블록디바이스(/dev/dsk) 와 로(RAW)디바이스(/dev/rdsk) 로 구분을 합니다.

단어 그대로 이해를 한다면 블록디바이스에 블록은 파일시스템의 블록을 말하는 겁니다.

즉 로디바이스위에 파일시스템이 얹어 있다고 보면 됩니다.

OS 는 어플리케이션의 IO 요구에 따라 파일 시스템에서 읽어 오느냐 ,

로 디바이스(파일시스템 보다는 더 하위레벨)에서 읽어 오느냐가 억세스 방법에 의해서

차이가 있습니다.

로 디바이스는 파일시스템이 없기 때문에 당현히 파일, 디렉토리, 억세스컨트롤 등을

어플리케이션에서 직접 관리 해야 합니다.

로 디바이스를 데이타베이스에서 사용할 때 데이타 베이스는 자체적으로 블록과 익스텐트 등의

스토리지 관리 개념을 가지고 있기 때문에 OS레벨에서의 물리적인 데이타 파일 관리만 하면 됩니다.

(데이타 베이스에서 로디바이스를 사용하더라도 물리적인 디바이스(디스크)에 데이타 파일형태로 위치해야

하기 때문에 볼륨매니저 같은 가상 스토리지 개념이 필요합니다.)

일반적인 디스크는 I/O 다음과 같은 패스를 가집니다.

Application<->Library Buffer<->Operation System Cache<->File System/Volume Manager<->Device

그런데 로디바이스의 패스는 다음과 같습니다.

Application<->Device


흔히 DBMS 를 컨피그할때 데이타 파일의 위치를 놓고 RAW 와 파일시스템 비교를 많이 하게 됩니다.

나름대로 장단점이 있어 쉽게 판단 할수는 없지만 파일관리측면에선 파일시스템이 성능면에서는 로 디바이스가 낫습니다.

DBMS 시스템에서 파일시스템을 사용 할 경우 DBMS 의 가 자체 IO버퍼를 설정 하기 때문에

OS 의 파일시스템 캐시가 필요 없습니다. 이런 파일시스템의 단점을 보완하고자 솔라리스의 Direct I/O , 베리타스 파일시스템등

이 나오게 되었습니다. 이와 같은 더블 버퍼링 를 막음으로써 OS는 메모리 파일시스템 캐싱을 위한 메모리 매니지먼트가 필요없어지고,

DBMS 에서만 버퍼링을 하므로 메모리를 덜 소모하게 됩니다. 주소 변환을 할 필요가 없으니 캐시의 억세스 속도도 빨라지겠죠.

RAW의 장점을 하나더 말씀드리면 KAIO(kernal async IO) 입니다.

위의 IO패스에서 보듯이 로디바이스는 IO요구가 발생될때 유저라이브러리를 사용 하지 않고 커널 레벨에서 IO 가 이루어 지므로

명령이 단순해 져서 결과적으론 CPU를 덜 사용하게 됩니다.


출처 : http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=10302&docId=63819461&qb=cmF3IGRldmljZQ==&enc=utf8&section=kin&rank=3&sort=0&spq=0&pid=fIe7Og331yosssEVpKlssv--169396&sid=S6RJEjE8pEsAACHkFto

'OS_NETWORK_Storage' 카테고리의 다른 글

vi 에디터 문자 모두 바꾸기  (0) 2011.03.14
XA 와 nonXA  (1) 2011.02.06
alias 추가  (0) 2009.12.08
쉘(shell)과 커널(kernel)  (1) 2009.10.05
Subnet Mask  (0) 2009.10.05
Posted by 자수성가한 부자
Oracle/Admin2010. 2. 25. 18:55
질문 :

index에 관해서 공부를 하다가 궁금한 점이 있어 이렇게 질문을 등록합니다.

테이블에 데이터가 자주 들락날락해서 delete된 데이터의 index가 그대로 남아있어, 필요이상으로 많은 공간을 차지할 때 한다는 것을 알고 있습니다.

그런데, 이렇게 필요이상으로 index가 공간을 많이 차지한다는 것을 어떻게 알 수 있을까요?





답변1 :

아래에 있는 두 방법의 결과로 판단합니다.


첫번째 방법 :

우선 분석하고자 하는 인덱스에 대한 통계정보를 생성합니다.

SQL> analyze index 인덱스명 compute statistics;
-- 수백만건 이상의 row를 지닌 테이블에 대한 인덱스인 경우 compute statistics 대신에 estimate 옵션을 사용할 것.


아래 쿼리 결과의 blevel값이 4가 넘으면 index rebuild를 하는 것이 좋습니다.
이 blevel(Branch level)이 의미하는 것은 오라클이 index access를 할 때 몇 단계를 거쳐서 블럭의 위치를 찾아가는 가와 관계가 있습니다.

SQL> select index_name, blevel
     from user_indexes
     where index_name = '인덱스명';


두번째 방법 :

아래의 쿼리를 이용하여 index_stats테이블에 추가적인 인덱스 정보를 생성합니다.

SQL> analyze index 인덱스명 validate structure;


아래 쿼리 결과의 pct_deleted가 20%이상으로 나타나면 rebuild 대상입니다.

그리고 distinctiveness는 인덱스가 만들어진 컬럼의 값이 얼마나 자주 반복되는지를 보여주는 값입니다.

예를 들면, 만일 1만건의 row와 9000건의 서로 다른 값을 가진 테이블이 있을 때 distinctiveness값은 다음과 같이 계산됩니다.

(10000-9000)*100/10000 = 10        => 컬럼의 값이 잘 분산되어 있음

또 다른 예를 들면, 1만건의 row가 있지만 2가지 값으로만 중복되어 있다면 distintiveness값은

(10000-2)*100/10000 = 99.98        => rebuild 대상이 아니라 bitmap index로 만들 대상(99%이상이면 bitmap index 대상)

SQL> select del_lf_rows*100/decode(lf_rows,0,1,lf_rows) pct_deleted,
            (lf_rows-distinct_keys)*100/decode(lf_rows,0,1,lf_rows) distinctiveness
     from index_stats
     where name = '&index_name';




답변2 :

답변2도 답변 1과 같은 내용이지만 스크립트를 사용함으로써, 한번에 여러개의 rebuild 대상 index를 찾을 수 있다는 장점이 있다.


결과 정보를 휘발성으로 저장하는데, 그 결과를 통해서 rebuild 대상을 체크할 수 있음.
주의할 점은 아래의 쿼리 실행시 Lock이 발생하므로, 업무시간 이외에 할 것을 강추함.

SQL> analyze index index_name validate structure ;


rebuild_indx.sql

REM =============================================================
REM
REM rebuild_indx.sql
REM
REM Copyright (c) Oracle Software, 1998 - 2000
REM
REM Author : Jurgen Schelfhout
REM
REM The sample program in this article is provided for educational
REM purposes only and is NOT supported by Oracle Support Services.
REM It has been tested internally, however, and works as documented.
REM We do not guarantee that it will work for you, so be sure to test
REM it in your environment before relying on it.
REM
REM This script will analyze all the indexes for a given schema
REM or for a subset of schema's. After this the dynamic view
REM index_stats is consulted to see if an index is a good
REM candidate for a rebuild or for a bitmap index.
REM
REM Database Version : 7.3.X and above.
REM
REM =============================================================

prompt
ACCEPT spoolfile CHAR prompt 'Output-file : ';
ACCEPT schema CHAR prompt 'Schema name (% allowed) : ';
prompt
prompt
prompt Rebuild the index when :
prompt - deleted entries represent 20% or more of the current entries
prompt - the index depth is more then 4 levels.
prompt Possible candidate for bitmap index :
prompt - when distinctiveness is more than 99%
prompt
spool &spoolfile

set serveroutput on
set verify off
declare
c_name INTEGER;
ignore INTEGER;
height index_stats.height%TYPE := 0;
lf_rows index_stats.lf_rows%TYPE := 0;
del_lf_rows index_stats.del_lf_rows%TYPE := 0;
distinct_keys index_stats.distinct_keys%TYPE := 0;
cursor c_indx is
select owner, table_name, index_name
from dba_indexes
where owner like upper('&schema')
and owner not in ('SYS','SYSTEM');
begin
dbms_output.enable (1000000);
dbms_output.put_line ('Owner Index Name % Deleted Entries Blevel Distinctiveness');
dbms_output.put_line ('--------------- --------------------------------------- ----------------- ------ ---------------');

c_name := DBMS_SQL.OPEN_CURSOR;
for r_indx in c_indx loop
DBMS_SQL.PARSE(c_name,'analyze index ' || r_indx.owner || '.' ||
r_indx.index_name || ' validate structure',DBMS_SQL.NATIVE);
ignore := DBMS_SQL.EXECUTE(c_name);

select HEIGHT, decode (LF_ROWS,0,1,LF_ROWS), DEL_LF_ROWS,
decode (DISTINCT_KEYS,0,1,DISTINCT_KEYS)
into height, lf_rows, del_lf_rows, distinct_keys
from index_stats;
--
-- Index is considered as candidate for rebuild when :
-- - when deleted entries represent 20% or more of the current entries
-- - when the index depth is more then 4 levels.(height starts counting from 1 so > 5)
-- Index is (possible) candidate for a bitmap index when :
-- - distinctiveness is more than 99%
--
if ( height > 5 ) OR ( (del_lf_rows/lf_rows) > 0.2 ) then
dbms_output.put_line (rpad(r_indx.owner,16,' ') || rpad(r_indx.index_name,40,' ') ||
lpad(round((del_lf_rows/lf_rows)*100,3),17,' ') ||
lpad(height-1,7,' ') || lpad(round((lf_rows-distinct_keys)*100/lf_rows,3),16,' '));
end if;

end loop;
DBMS_SQL.CLOSE_CURSOR(c_name);
end;
/

spool off
set verify on
- - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - - - - - -


샘플 결과

Sample Output
-------------

Rebuild the index when:

- deleted entries represent 20% or more of the current entries.
- the index depth is more then 4 levels.

Possible candidate for bitmap index:

- when distinctiveness is more than 99%

Owner Index Name % Deleted Entries Blevel Distinctivenes
--------------- ------------------------- ----------------- ------ -------------
SMS PLATMAP_I1 31.504 1 32.927
SMS PLATMAP_I2 27.682 1 29.399
SMS PLATMAP_I3 31.237 1 31.237
SMS PRODMAP_I4 8.765 5 99.9
SMS SB_CR_BOM_ITEMS_I1 34.496 2 97.356
SMS SB_CR_OS_VERSIONS_I1 51.942 1 68.063
SMS SB_CR_RELEASES_I1 34.584 1 18.426
SMS TAR_HEAD_I2 21.728 5 22.344

PL/SQL procedure successfully completed.


참조 : http://cafe.naver.com/prodba/16759
         http://oracleclub.com/article/46676

'Oracle > Admin' 카테고리의 다른 글

create index, index rebuild  (0) 2010.04.27
alert_SID.log  (0) 2010.03.24
Globalization  (0) 2010.01.11
Security  (0) 2010.01.08
Resource Manager  (0) 2010.01.07
Posted by 자수성가한 부자
Oracle/기타2010. 2. 24. 11:24
질문 :

테이블 A에 1,2,3,4,5,6,7  이라는 컬럼이 있습니다.

1,2,3 에는 그냥 고정값 a,b,c,가 각각 들어가고

4에는 해당 날짜 시간

5,6,7에는  5에는 4에서 적힌 년, 6에는 4에서 찍힌 월,7에는 4에서 찍힌  일을 넣을려고 합니다.

 

 1  2  3  4  5  6  7
 a  b  c  2009-09-05 00:00:30  2009  09 05
 a  b  c  2009-09-05 00:01:00  2009  09  05
 a  b  c  2009-09-05 00:01:30  2009  09  05


.

.

.

.

이런식으로 해서 30초 4컬럼에 30초 간격으로 오늘 날짜 까지 데이터를 30초 간격으로 넣어줄려고 하는데;;

어떻게 해야 하는지 모르겠네요.;;

데이터 출력을 위해서 임의의 값을 넣는건데.. 5,6,7 컬럼은 4의 값을 넣어야하고;;

2009년 9월부터 해서 오늘 일까지 30초 간격으로 데이터 넣는 방법좀 가르쳐주세여.ㅜ_ㅜ

데이터가 너무 많아서 인서트 적기는 힘드네요..ㅜ_ㅜ

 

부탁드리겠습니다





답변 :

먼저 테이블을 생성해줍니다.

SQL> create table t1(col1 varchar2(1),
                     col2 varchar2(1),
                     col3 varchar2(1),
                     col4 date,
                     col5 varchar2(4),
                     col6 varchar2(2),
                     col7 varchar2(2));



그리고 insert하려는 쿼리의 row수가 얼마나 되는지 알아봅니다.

SQL> select (sysdate-to_date('2009-09-05 00:00:30','YYYY-MM-DD HH24:MI:SS'))*24*60*60/30 "level"
     from dual;



위 쿼리의 결과의 정수부분만 아래 쿼리의 level 뒤에 넣어줍니다.


SQL> insert into t1
     select 'a','b','c',
            to_date('2009-09-05 00:00:30','YYYY-MM-DD HH24:MI:SS')+(level-1)/24/60/60*30,
            to_char(to_date('2009-09-05 00:00:30','YYYY-MM-DD HH24:MI:SS')+(level-1)/24/60/60*30, 'YYYY'),
            to_char(to_date('2009-09-05 00:00:30','YYYY-MM-DD HH24:MI:SS')+(level-1)/24/60/60*30, 'MM'),
            to_char(to_date('2009-09-05 00:00:30','YYYY-MM-DD HH24:MI:SS')+(level-1)/24/60/60*30, 'DD')
     from dual
     connect by level <= 위 결과의 정수부분 넣는 곳;



PS) 참고로 날짜가 년월일밖에 나오지 않는다면 아래와 같이 세션의 날짜포맷을 변경해줍니다.


SQL> alter session set nls_date_format = 'DD-MON-RR HH24.MI.SS';


질문과 답변 원문 : http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=10205&docId=105498493

'Oracle > 기타' 카테고리의 다른 글

database의 feature의 사용유무 체크뷰  (0) 2010.05.04
데이터베이스 명의 최대 바이트 수는?  (0) 2010.04.01
import 성능 향상시키는 방법  (0) 2010.02.11
reorganization  (0) 2010.02.11
Read the alert log with SQL  (0) 2010.01.13
Posted by 자수성가한 부자
Oracle/용어정리2010. 2. 22. 14:34

클러스터링 팩터(Clustering Factor)란?

군집성 계수(= 데이터가 모여있는 정도)라고 번역될 수 있다.
데이터베이스에서는 특정 컬럼을 기준으로 같은 값을 갖는 데이터가 서로 모여있는 정도를 의미한다.
"인덱스 클러스터링 팩터가 좋다."고 하면 인덱스 정렬 순서와 테이블 정렬 순서가 서로 비슷하다는 것을 말한다.


클러스터링 팩터는 왜 알아야 하는가?

두가지 면에서 성능에 영향을 미치기 때문이다.
1. Index Scan의 Cost에 큰 영향을 준다.
2. Index Lookup을 통해 Data를 읽는 일량을 결정한다.


클러스터링 팩터는 어느 테이블, 어느 컬럼에서 확인할 수 있을까?

dba_indexes,
all_indexes,
user_indexes테이블의  clustering_factor컬럼에서 확인할 수 있다.


클러스터링 팩터의 값은 어떻게 계산되어 나오는 것일까?

clustering_factor 계산을 위해서 오라클이 사용하는 아래의 로직을 보고 나면 값을 유추해낼 수 있다.

1. counter 변수를 선언.
2. 인덱스 리프 블록을 처음부터 끝까지 스캔하면서 인덱스 rowid로부터 블록 번호를 취함. 
3. 현재 읽고 있는 인덱스 레코드의 블록 번호가 바로 직전에 읽은 레코드의 블록 번호와 다를 때마다 counter값을 1씩 증가시킨다.
4. 스캔을 완료하고서, 최종 counter변수 값을 clustering_factor로서 인덱스 통계에 저장한다.

테이블 통계를 수집하지 않고, clustering_factor를 구하는 스크립트 =>> 클릭


그럼 실제적으로 테스트를 통해 클러스터링 팩터를 확인해보자.


1. 1000개의 데이터가 index와 같은 순서로 되어있을 경우


OS] sqlplus test/test
SQL> create table t1(col1 number, col2 varchar2(10));
SQL> insert into t1
     select level, 'test'
     from dual
     connect by level <= 1000;


클러스터링 팩터 : 4

SQL> select index_name, table_owner, table_name, clustering_factor
     from user_indexes
     where index_name = 'T1_COL1_IDX';

 

INDEX_NAME TABLE_OWNER TABLE_NAME CLUSTERING_FACTOR
T1_COL1_IDX TEST T1 4


2. 1000개의 데이터가 index와 정반대의 순서로 되어있을 경우


OS] sqlplus test/test
SQL> create table t2(col1 number, col2 varchar2(10));
SQL> insert into t2
     select 1001-level, 'test'
     from dual
     connect by level <=1000;

SQL> create index t2_col1_idx on t2(col1);


클러스터링 팩터 : 4

SQL> select index_name, table_owner, table_name, clustering_factor
     from user_indexes
     where index_name = 'T2_COL1_IDX';


INDEX_NAME TABLE_OWNER TABLE_NAME CLUSTERING_FACTOR
T2_COL1_IDX TEST T2 4



3. 1000개의 데이터가 랜덤으로 되어있을 경우

OS] sqlplus test/test
SQL> create table t3(col1 number, col2 varchar2(10));
SQL> insert into t3
     select dbms_random.value(1,1000), 'test'
     from dual
     connect by level <= 1000;
SQL> create index t2_col1_idx on t3(col1);


클러스터링 팩터 : 881

SQL> select index_name, table_owner, table_name, clustering_factor
     from user_indexes
     where index_name = 'T3_COL1_IDX';


INDEX_NAME TABLE_OWNER TABLE_NAME CLUSTERING_FACTOR
T3_COL1_IDX TEST T3 881



참고 : Optimizing Oracle Optimizer p.117 ~ 137
         오라클 성능 고도화 원리와 해법 2  P.67 ~ 78

'Oracle > 용어정리' 카테고리의 다른 글

TPS 란?  (1) 2011.02.02
BCP (Business Continuity Planning)  (0) 2010.12.26
정규화란?  (1) 2010.02.04
옵티마이져(Optimizer)란?  (0) 2010.02.04
FGA  (0) 2009.12.23
Posted by 자수성가한 부자
Oracle/기타2010. 2. 11. 19:03

Import 성능 향상시키는 방법


Oracle에서 테이블의 재구성(table reorganization) 또는 데이터 이동(data migration)을 하는 경우 많은 양의 데이터를 import할 경우가 있습니다. 성능향상을 위한 몇 가지 방법을 소개하니 참고 바랍니다…


1. 파라미터 파일에서 BUFFER SIZE를 크게 하세요~ 이렇게 함으로서 디스크 I/O가 줄게되어 성능이 개선 됩니다.


2. 항상 indexes=N로 하시구요… 테이블의 데이터를 먼저 import한 후 Oracle Server에서 index를 rebuild 하는 것이 훨씬 좋습니다.


3. 파라미터 파일에서 COMMIT=N로 하세요… 
   이렇게 하면 클 ROLLBACK SEGMENT를 필요로 하지만 각각의 BUFFER를 import후 commit하는 것이 아니라 
   TABLE을 몽땅 import후 commit하게 됩니다.


4. 하나의 큰 dedicated rollback segment를 쓰는 것이 좋습니다. 이렇게 하기 위해서는 다른 rollback segment는 offline 시키시면 되구요… 
   하나뿐인 rollback segment의 사이즈는 가장 큰 테이블의 50% 정도 잡으시면 됩니다.


5. import가 끝날 때 까지 DB운영을 NOARCHIVELOG mode로 하세요~


출처 : http://www.oracleclub.com/article/10863?article.communityId=1683&article.end=20&categoryId=0&pageNo=9&searchKey=CONTENT&searchValue=

Posted by 자수성가한 부자
Oracle/기타2010. 2. 11. 18:59
reorganization이란?

글자그대로 해석하면 재조직이다.
오라클에서에 이 재조직이라 함은 table, index, sequence과 같은 오브젝트를 기존과는 다른 형태로 재구성한다는 것이 아닐까?


reorganization에는 어떤 것들이 있을까?



reorganization이 필요하다는 것은 어떻게 알 수 있을까?

analyze


실제적으로 실습을 해보자.


SQL> alter table 테이블명 dellocate unused;


SQL> alter index 인덱스명 rebuild (다양한 옵션);


create table
as
select  SQL문

export/import utilities

SQL*Loader

alter table move tablespace

온라인 reorganization
DBMS_REDEFINITION


참고 : http://blog.naver.com/orapybubu?Redirect=Log&logNo=40021506268
         http://blog.naver.com/orapybubu?Redirect=Log&logNo=40045446472
         http://blog.naver.com/imbyuri?Redirect=Log&logNo=110070124618
         http://kr.forums.oracle.com/forums/thread.jspa?messageID=1465894

'Oracle > 기타' 카테고리의 다른 글

오라클 30초 간격으로 동일한 값 넣는 쿼리  (1) 2010.02.24
import 성능 향상시키는 방법  (0) 2010.02.11
Read the alert log with SQL  (0) 2010.01.13
[펌]오라클의 뷰가 만들어지는 과정  (0) 2009.12.23
login.sql셋팅  (0) 2009.12.15
Posted by 자수성가한 부자