2026년 3월 3일 화요일

Greenplum Ghost Index

Greenplum 7.6+에서 Ghost Index(Implied index)를 지원합니다.

1. Ghost Index 개념
   - 컬럼 압축테이블(AO/CO)에 blockdirectory 옵션을 적용하여, 
      인덱스가 없더라도 Block 정보로 인덱스 처럼 활용
   - 적용 방법

CREATE TABLE gpkrtpch.LINEITEM_col_bd (LIKE gpkrtpch.lineitem)
with (appendonly=true, compresstype=zstd, compresslevel=7
, orientation=COLUMN, blockdirectory=true)
DISTRIBUTED BY(L_ORDERKEY)

2. Ghost Index 장점 
1) 성능
   - B-tree 인데스보다는 느리지만, Full Scan보다는 빠름. 
   - B-tree 인데스는 인덱스 컬럼에 대해서만 빠르지만, Ghost Index는 모든 컬럼에 대해서 성능 개선 
2) 용량
   - 인덱스 생성이 필요 없음 (인덱스 생성에 필요한 용량이 없음.) 
   - 컬럼 압축시 Block Directory 정보로 약 2.5% 용량 필요.  
   - row 압축보다 컬럼 압축율이 높기 때문에 전체 사이즈는 더 절약.

3. Ghost Index 테스트 결과 
    - 데이터 소스: https://github.com/gpdbkr/gpkrtpch 
    - Ghost index 테스트 스크립트: https://github.com/gpdbkr/Greenplum7/tree/main/ghost_index
    - 사이즈: row 압축 대비 column 압축시 40% 용량 감소
    - 성능   : Full Scan 대비 5~6배 성능 향상(단, B-Tree 인덱스와의 성능은 차이 발생) 

1) 테이블 사이즈 (단위 : MB)
 - com_row: row 압축 테이블 
 - com_row_idx: row 압축 테이블 + Btree 인덱스 
 - com_col : column 압축 테이블 
 - com_col_bd : column 압축 테이블 + Block Directory 옵션 적용
 - com_col_bd_idx : column 압축 테이블 + Block Directory 옵션 적용 + Btree 인데스 

 schema_nm |        tb_nm        | tb_size_mb | ix_size_mb | tot_size_mb
-----------+---------------------+------------+------------+-------------
 gpkrtpch  | lineitem_col        |        477 |          0 |         477
 gpkrtpch  | lineitem_col_bd     |        489 |          0 |         489
 gpkrtpch  | lineitem_col_bd_idx |        489 |        392 |         881
 gpkrtpch  | lineitem_row        |        811 |          0 |         811
 gpkrtpch  | lineitem_row_idx    |        823 |        392 |        1215

2) 쿼리 성능 (단위 : sec) 
- select_count : 단순 테이블 건수 체크 
- select_2cols  : where 조건 필터링 후 2개 컬럼만 추출
- select_8cols  : where 조건 필터링 후 8개 컬럼만 추출

filename                          | com_row | com_row_idx | com_col |com_col_bd |com_col_bd_idx |
------------------------------------------------------------------------------------------------
ghost_index.1.1.drop_tb.sql       |   0.613 |       0.788 |   0.450 |     0.590 |         0.636 |
ghost_index.1.2.crt_tb.sql        |   0.510 |       0.409 |   0.575 |     0.712 |         0.710 |
ghost_index.2.1.insert.sql        | 118.667 |     119.498 |  93.739 |    97.950 |       103.820 |
ghost_index.2.2.crt_idx.sql       |   0.013 |      20.596 |   0.001 |     0.000 |        13.445 |
ghost_index.3.1.analyze.sql       |  20.584 |      20.665 |  20.455 |    21.282 |        21.078 |
ghost_index.4.1.select_count.sql  |   7.996 |       7.807 |   2.666 |     2.412 |         2.617 |
ghost_index.4.2.select_2cols.sql  |   1.213 |       0.017 |   0.431 |     0.166 |         0.036 |
ghost_index.4.3.select_4cols.sql  |   1.120 |       0.022 |   0.636 |     0.167 |         0.042 |
ghost_index.4.4.select_8cols.sql  |   1.198 |       0.018 |   0.877 |     0.192 |         0.022 |
ghost_index.4.5.select_16cols.sql |   1.100 |       0.018 |   1.672 |     0.189 |         0.023 |




Greenplum Ghost Index

Greenplum 7.6+에서 Ghost Index (Implied index)를 지원합니다. 1. Ghost Index 개념    - 컬럼 압축테이블(AO/CO)에 blockdirectory 옵션을 적용하여,        인덱스가 없더라도 Block...