문서유형ㅣ기술정보
분야ㅣ관리/환경설정
적용제품버전ㅣ7FS02PS
문서번호ㅣTADTI100
개요
방법
테스트환경
[tibero7@rocky9.4:T724:/home/tibero]tbboot -version
Tibero 7 (DB 7.2.4) Build 303667
Linux bistro-build-centos_8.4 5.15.0-134-generic #145~20.04.1-Ubuntu SMP Mon Feb 17 13:27:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux version (little-endian)
Patch files (FS02PS_700093a FS02PS_700103a FS02PS_344166f FS02PS_700110a FS02PS_342949f)
Compiled with "cc -no-pie -ggdb -fstack-protector-all -fno-strict-aliasing -fno-omit-frame-pointer -pipe -O3 -D_OPT_COMPILED -U_FORTIFY_SOURCE -D_USE_VIP -Wall -W -Werror-implicit-function-declaration -Wno-unused-parameter -Wpointer-arith -Wdeclaration-after-statement -DHAVE_CONFIG_H -D_WORDSIZE=64 -D_OS_LINUX -D_LINUX_X86_64 -D_X86 -DUSE_ASSERT -DTSAM -DTSAM_NO_ESDS_SEQUENCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_USE_FSYNC -D_CHECK_LICENSE -D_STBLOG -D_TAC -DFD_SETSIZE=8192 -D_CM_OBSERVER -D_USE_FALLOCATE -D_GNU_SOURCE -D_GNU_SOURCE -D_GNU_SOURCE -D_GNU_SOURCE -DHAVE_EPOLL"
Compiled at Oct 13 2025 01:59:51 build seq 303667 init rev {2023-11-24}
예제 테이블 데이터 생성
drop table acc1;
drop table acc2;
create table acc1(accno number, amt number, tamt number);
create table acc2(accno number, amt number, tamt number);
insert into acc1 select level, 1000, 2000 from dual connect by level <= 100000;
insert into acc2 select level, 1000, 2000 from dual connect by level <= 100000;
ALTER TABLE acc1 ADD CONSTRAINT PK_acc1_accno PRIMARY KEY(accno);
ALTER TABLE acc2 ADD CONSTRAINT PK_acc2_accno PRIMARY KEY(accno);
exec dbms_stats.gather_table_stats('TIBERO','ACC1',estimate_percent=>100,method_opt=>'FOR ALL COLUMNS SIZE 254');
exec dbms_stats.gather_table_stats('TIBERO','ACC2',estimate_percent=>100,method_opt=>'FOR ALL COLUMNS SIZE 254');
예제 수행
다음 예제에서 Current, Consistent 모드 읽기가 복합적으로 사용된 경우를 확인할 수 있습니다.
- Current 모드: 계좌1.잔고
- Consistent 모드: 계좌2.잔고 update 계좌1
update 계좌1
set 계좌1.총잔고
= 계좌1.잔고 + (select 계좌2.잔고 from 계좌2 where 계좌2.계좌번호=계좌1.계좌번호)
where 계좌1.계좌번호=7788;계좌1.잔고 는 Current모드로 읽고, 계좌2.잔고는 Consistent 모드로 읽습니다.
update중 계좌2에 변경이 발생해도 update, delete 문이 시작되는 시작점(변경전) 값을 사용합니다.
다음 실행 예제에서 Session B 의 UPDATE 구문을 통해 계좌1.총 잔고는 1100+1000, 즉 2100 이 됩니다.
No | Session A | Session B |
| 1 | SQL>select acc1.amt acc1_amt,
| |
| 2 | SQL>update acc1 set amt=amt+100 where accno=7788; | |
| 3 | SQL>update acc2 set amt=amt+200 where accno=7788; | |
| 4 | SQL>select acc1.amt acc1_amt, acc2.amt acc2_amt, acc1.tamt acc1_tamt, acc1.amt+acc2.amt sum_amt from acc1, acc2 where acc1.accno=7788 and acc2.accno=acc1.accno; ACC1_AMT ACC2_AMT ACC1_TAMT SUM_AMT ---------- ---------- ---------- ---------- 1100 1200 2000 2300 | SQL>select acc1.amt acc1_amt, acc2.amt acc2_amt, acc1.tamt acc1_tamt, acc1.amt+acc2.amt sum_amt from acc1, acc2 where acc1.accno=7788 and acc2.accno=acc1.accno; ACC1_AMT ACC2_AMT ACC1_TAMT SUM_AMT ---------- ---------- ---------- ---------- 1000 1000 2000 2000 |
| 5 | SQL>update acc1 set acc1.tamt = acc1.amt +(select acc2.amt from acc2 where acc2.accno = acc1.accno) where acc1.accno = 7788; | |
| 6 | (no.2) 에서 발생한 row lock (acc1 테이블의 accno=7788 에 해당하는 row) 을 대기함 | |
| 7 | SQL>commit; | |
| 8 | - (no.7)commit 이후에 update 수행됨 - acc1.amt 는 update 대상 row 이므로, current 읽기 모드 수행(acc1.amt 값은 1100 사용함). | |
| 9 | SQL>select acc1.amt acc1_amt,
| SQL>select acc1.amt acc1_amt,
|
| 10 | SQL>commit; | |
| 11 | SQL> select acc1.amt acc1_amt,
| SQL> select acc1.amt acc1_amt,
|
참고
Consistent Mode
- SQL trace 에서의 명칭: query
- tbSQL 의 autotrace 에서의 명칭 : consistent gets
- TSN(Tibero System Number)확인 과정을 거치며 읽기 일관성이 보장된 상태에서 데이터 블록을 읽습니다.
- 대부분 SELECT 쿼리가 해당되며, 쿼리가 시작된 시점을 기준으로 일관성 있게 읽어 들이고 읽는 도중에 값이 바뀌더라도 쿼리 시작 시점의 값으로 읽습니다.
- TSN의 값을 확인하면서 읽는데 값이 변경되면 TSN번호가 증가 되므로 이 경우에는 언두 세그먼트(UNDO Segment)에서 과거의 블록을 읽어서 처리하는 CR(Consistent Read) block 작업이 발생하며, CR블럭을 읽게 되고, SQL AUTOTRACE에서는consistent gets로 표시됩니다.
- current 블록을 읽더라도 consistent 모드로 읽을 경우는 SQL AUTOTRACE 에서 consistent gets 로 표시 됩니다.
Current Mode
- SQL trace 에서의 명칭: current
- tbSQL 의 autotrace 에서의 명칭 : db block getsSQL 시작시점이 아닌 실제 블록을 액세스하는 그 시점의 최종값을 읽어들이는데 주로 발생하는 경우는 다음과 같습니다.
- DML 또는 디스크 소트가 필요할 정도의 대용량 정렬시
- SELECT FOR UPDATE 수행 시
- table full scan 시 대상 세그먼트의 익스텐트 정보를 읽을 때