Greenplum 설정
Greenplum 설정
dbt-greenplum 어댑터에서 모델별로 성능 최적화 설정을 하는 방법을 다루는 페이지예요. Greenplum 테이블은 분산(distribution), 컬럼 지향(column orientation), 압축(compression), appendonly 토글, 파티션 등 강력한 최적화 구성을 제공해요. 모델 레벨에서 이 값들을 지정하면 생성되는 CREATE TABLE에 해당 설정이 자동으로 반영된답니다.
출처: 문서
본문
성능 최적화 (Performance Optimizations)
Greenplum의 테이블은 쿼리 성능을 높이기 위한 강력한 최적화 구성을 갖고 있어요:
- 분산(distribution)
- 컬럼 지향(column orientation)
- 압축(compression)
appendonly토글- 파티션(partitions)
이 값들을 모델 레벨 구성으로 지정하면 생성되는 CREATE TABLE에 해당 설정이 적용돼요(파티션 제외). 단, view로 설정된 모델에는 이 설정이 아무 효과가 없어요.
분산 (Distribution)
Greenplum에서는 distribution key를 선택할 수 있는데, 이 키로 데이터를 세그먼트별로 정렬해요. 분산을 지정하면 파티션 기준으로 조인할 때 성능이 좋아져요.
기본적으로 dbt-greenplum은 데이터를 RANDOMLY로 분산시켜요. distribution key를 사용하려면 모델 config에 distributed_by 파라미터를 지정하세요:
{{
config(
...
distributed_by='<field_name>'
...
)
}}
select ...
DISTRIBUTED REPLICATED 옵션도 선택할 수 있어요:
{{
config(
...
distributed_replicated=true
...
)
}}
select ...
컬럼 지향 (Column orientation)
Greenplum은 row와 column 두 가지 오리엔테이션을 지원해요:
{{
config(
...
orientation='column'
...
)
}}
select ...
압축 (Compression)
압축은 읽기-쓰기 시간을 줄여줘요. Greenplum은 append-optimized 테이블을 압축하기 위한 여러 알고리즘을 제공해요:
- RLE_TYPE (컬럼 지향 테이블에만 해당)
- ZLIB
- ZSTD
- QUICKLZ
{{
config(
...
appendonly='true',
compresstype='ZLIB',
compresslevel=3,
blocksize=32768
...
)
}}
select ...
보시다시피 compresslevel과 blocksize도 함께 지정할 수 있어요.
파티션 (Partition)
Greenplum은 create table as 구문으로 파티션을 지원하지 않아서, 모델을 두 단계로 나눠서 만들어야 해요:
- 테이블 스키마 생성
- 데이터 삽입
dbt 모델에 파티션을 구현하려면 다음 config 파라미터를 지정해야 해요:
fields_string- 컬럼 이름, 타입, 제약 조건 정의raw_partition- 파티션 명세
{% set fields_string %}
some_filed int4 null,
date_field timestamp NULL
{% endset %}
{% set raw_partition %}
PARTITION BY RANGE (date_field)
(
START ('2021-01-01'::timestamp) INCLUSIVE
END ('2023-01-01'::timestamp) EXCLUSIVE
EVERY (INTERVAL '1 day'),
DEFAULT PARTITION default_part
);
{% endset %}
{{
config(
...
fields_string=fields_string,
raw_partition=raw_partition,
...
)
}}
select *
더 알아보기 (Learn more)
- Greenplum 공식 문서: Distribution과 Storage (orientation/compression)에서 테이블 최적화 설정을 더 자세히 볼 수 있어요.
- dbt의 일반적인 모델 설정은 define-configs 항목을 참고하세요.