728x90

14.10.xC6 버전부터 Round robin 방식으로 분할된 테이블의 개선된 기능을 소개드립니다.

Round robin 분할 방식로 구성된 테이블은 데이터가 지정된 DBspace를 순환하며 입력됩니다.

-- Round robin 분할 테이블에 데이터 입력
> create table test (a int) fragment by round robin in dbs1,dbs2;
Table created.
> insert into test select level from sysmaster:sysdual connect by level <= 5000;
5000 row(s) inserted.
-- 분할된 파티션 별 데이터 건수 확인
$ oncheck -pt demo:test | egrep 'partition|rows'
                  Table fragment partition dbs1 in DBspace dbs1
    Number of rows                 2500
                  Table fragment partition dbs1 in DBspace dbs2  
    Number of rows                 2500

위와 같은 상태에서 새로운 DBspace를 round robin 스키마에 추가하면, 기존 데이터는 이동하지 않고 새로 입력되는 데이터는 기존처럼 DBspace를 순환하며 입력됩니다.

-- Round robin 분할 테이블에 새로운 DBspace 추가
> alter fragment on table test add  dbs3;
Alter fragment completed.
> insert into test select level from sysmaster:sysdual connect by level <= 3;
3 row(s) inserted.
-- 분할된 파티션 별 데이터 건수 확인
$ oncheck -pt demo:test | egrep 'partition|rows'
                  Table fragment partition dbs1 in DBspace dbs1
    Number of rows                 2501
                  Table fragment partition dbs2 in DBspace dbs2
    Number of rows                 2501
                  Table fragment partition dbs3 in DBspace dbs3
    Number of rows                 1

14.10.xC6 버전부터는 Round robin 방식으로 구성된 테이블에 데이터가 입력될 경우, 가장 데이터 건수가 적은 파티션에 우선적으로 입력됩니다.

-- Round robin 분할 테이블에 데이터 입력
> create table test (a int) fragment by round robin in datadbs1,datadbs2;
Table created.
> insert into test select level from sysmaster:sysdual connect by level <= 5000;
5000 row(s) inserted.
-- Round robin 분할 테이블에 새로운 DBspace 추가
> alter fragment on table test add datadbs3;
Alter fragment completed.
> insert into test select level from sysmaster:sysdual connect by level <= 3;
3 row(s) inserted.
-- 분할된 파티션 별 데이터 건수 확인
$ oncheck -pt demo:test | egrep 'partition|rows'
                  Table fragment partition datadbs1 in DBspace datadbs1
    Number of rows                 2500
                  Table fragment partition datadbs2 in DBspace datadbs2
    Number of rows                 2500
                  Table fragment partition datadbs3 in DBspace datadbs3
    Number of rows                 3

 

파티션 별로 데이터량을 균등하게 유지하는 측면에서 좋은 기능인 것 같습니다. UPDATE 문장으로는 데이터가 이동하지 않더군요. 참고하시길 바랍니다.

 

728x90
728x90

예전에 Ben Thompson의 블로그에서 Index fragment의 page limit에 대한 글을 읽었습니다.

2014년의 글인데 Index의 페이지 수가 12.1버전부터 2^31 (2,147,483,647)개로 증가했다는 것이지요.

IBM Knowledge Center에도 문서화되어 있습니다.

https://www.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.adref.doc/ids_adr_0718.htm#ids_adr_0718__table

 

블로그의 저자인 Ben은 11.7 버전에서도 테스트해보았다는 내용이 있습니다. 그러나 IBM 문서에는 해당 내용이 없어서, IBM Community에 자문을 구하고자 질문을 올렸고 Art와 Ben이 몇가지 조언을 주어서 직접 테스트를 하게 되었습니다.

 

테스트 환경은 인포믹스 11.50.FC6과 11.70.FC5이고, 테스트 시나리오를 위해 고객사의 테이블 스키마를 사용했습니다.

고객은 인포믹스 11.7 버전을 사용하고 있고, 매달 생성하는 테이블이 있는데 최근 몇달간의 데이터를 보니 약 4억4천만건의 레코드가 저장되고 있더군요.

문제는 테이블은 라운드 로빈(round robin) 형태인데 primary key에 해당하는 unique index는 분할되지 않아 기존에 알고 있던 한계치인 2^24 (16,775,134) 개에 육박하고 있다는 점입니다.

그런데 막상 IBM Knowledge Center의 11.7 버전의 문서에는 인덱스 페이지 수의 제한은 나와있지 않고..

 

이런 상황을 가정하고 아래의 테이블을 만들었습니다.

create table log_12
  (
    col1 varchar (50),
    col2 varchar (32),
    col3 varchar (5),
    col4 varchar (5),
    col5 varchar (10)
   .....
  ) fragment by round robin in dbs1, dbs2, dbs3
extent size 16000000 next size 10000000;​

데이터 입력 시간을 절약하기 위해, 더미 데이터를 약 5억건 입력하고 아래 인덱스를 만들었습니다.

create unique index log_12_pk on log_12 (col1, col2, col3, col4, col5) in idx1;​

11.5에서는 인덱스의 페이지 수가 2^24 (16,775,134)개에 도달하자 인덱스를 생성하는 트랜잭션은 롤백되면서 online.log에는 아래와 같은 메시지가 출력되었습니다.

15:22:42 partition 'demo: informix.log_12_pk': no more pages

11.7에서는 인덱스 생성이 완료되었고, 인덱스에 35,999,944개의 페이지가 할당되었습니다.

아래는 oncheck -pt의 결과물의 일부입니다.

                  Index log_12_pk fragment partition idx1 in DBspace idx1
    Physical Address               5:5
    Creation date                  02/14/2020 16:47:53
    TBLspace Flags                 801        Page Locking
                                              TBLspace use 4 bit bit-maps
    Maximum row size               107
    Number of special columns      0
    Number of keys                 1
    Number of extents              2
    Current serial value           1
    Current SERIAL8 value          1
    Current BIGSERIAL value        1
    Current REFID value            1
    Pagesize (k)                   2
    First extent size              8672897
    Next extent size               5420560
    Number of pages allocated      35999944
    Number of pages used           35705525
    Number of data pages           0
    Number of rows                 0
    Partition partnum              5242882
    Partition lockid               2097217
    Extents
         Logical Page     Physical Page        Size Physical Pages
                    0              5:53    23999947   23999947
             23999947               9:3    11999997   11999997

인포믹스 11.7 이상이라면 인덱스 페이지 수 제한을 걱정하지 않아도 되겠군요.

 

추가로 IBM에 공식적으로 문의한 결과, 11.7 문서화에 명시되지 않았을 뿐 인덱스 페이지 수 제한은 12.1 버전과 마찬가지로 2^31 (2,147,483,647)개임을 확인했습니다.

728x90
728x90

Question

This document explains what a tblspace-tblspace (also referred as tablespace-tablespace and partition-partition) is and how it relates to other tables in an instance.

Answer

What is TBLspace TBLspace?

You are running IBM® Informix® Dynamic Server (IDS) database server and create a regular Dbspace. This Dbspace contains an internal table called TBLspace TBLspace. You cannot access the table using SQL commands.

What it does?

The TBLspace TBLspace table tracks all the partitions (tables or indexes) that you create in a Dbspace, including itself. You can track every table, detached index, or table fragment in the TBLspace TBLspace table through a partition page. The first partition page contains information about the TBLspace TBLspace table itself and the following partition pages track other tables. The partition page contains important information about a table and you can see part the data using theoncheck -pt command (oncheck  -pt database:table):


    oncheck   -pt database : table 

      database
        name of the database 
      table
        name of the table 

When you create a TBLspace TBLspace table, it has an initial extent of 50 pages on version 7.x and 250 pages on 9.x. In addition, when the first extent gets full, a new extent is allocated in one of the chunks of the Dbspace. This may cause a problem because if you create a new extent of the TBLspace TBLspace table on a chunk that needs to be dropped the server will report an error saying that the chunk is not empty. This will happen even if there is no user data in it. 
Even though the TBLspace TBLspace is not accessible through SQL you can still see the extents that are allocated in the chunks of the Dbspace using theoncheck -pe command. 

    Example: 

    The following is a partial output of an  oncheck -pe run on an IDS 7.x system. It is the first extent (50 pages) of the TBLspace TBLspace in chunk 2:

      DBspace Usage Report: dbs1        Ownner: informix  Created: 10/11/2003 

      Chunk: 2 /informix/dbs1_chunk1 Size Used  Free 
                                      5000   53  4947 

      Disk usage for Chunk 2      Start  Length 

      ------------------------------------------- 
       OTHER RESERVED Pages         0      2 
       CHUNK FREE LIST PAGE         2      1 
        TBLSPACE TBLSPACE             3      50 
       FREE                        53     4947 

      Chunk: 3 /informix/dbs1_chunk2 Size Used Free 
                                      5000   3  4997 
      Disk usage for Chunk 3        Start   Length 
      -------------------------------------------- 
         OTHER RESERVED Pages         0      2 
         CHUNK FREE LIST PAGE         2      1 
         FREE  


728x90
728x90

## 샘플 데이터


Row# CD SHOP_CD PER

1 SG A 9.37

2 SP B 14.71

3 SP A 5.71


Row# CD SHOP_CD PER

1 SG P 0

2 SG B 0

3 SG A 0

4 SP P 0

5 SP B 7.14

6 SP A 3.03



## CD 컬럼 기준으로 SHOP_CD 컬럼 데이터 그룹핑


with kk as (

select '1' as Row#, 'SG' as CD, 'A' as SHOP_CD, '9.37' as PER from dual

union all

select '2','SP','B','14.71' from dual

union all

select '3','SP','A','5.71' from dual

)

select CD,min(decode(cnt,1,SHOP_CD)) || ' & ' || min(decode(cnt,2,SHOP_CD))

from (select kk.*,row_number() over(partition by CD order by CD) cnt from kk) group by CD;


with kk as (

select '1' as Row#, 'SG' as CD, 'P' as SHOP_CD, '0' as PER from dual

union all

select '2','SG','B','0' from dual

union all

select '3','SG','A','0' from dual

union all

select '4','SP','P','5.71' from dual

union all

select '5','SP','B','7.14' from dual

union all

select '6','SP','A','3.03' from dual

)

select CD,min(decode(cnt,1,SHOP_CD)), min(decode(cnt,2,SHOP_CD)), min(decode(cnt,3,SHOP_CD))

from (select kk.*,row_number() over(partition by CD order by CD) cnt from kk)

group by CD;



http://blog.daum.net/_blog/BlogTypeView.do?blogid=0KEP0&articleno=7609595&categoryId=591133®dt=20100106103323

728x90

+ Recent posts