피드로 돌아가기
Dev.toDatabase
원문 읽기
MPP 최적화를 위한 GBase 8a 통계 테이블 기반 Query Plan 설계
GBase 8a Statistics Tables: Understanding gc_stats_table and gc_stats_column
AI 요약
Context
MPP 구조의 GBase 8a 데이터베이스에서 효율적인 Execution Plan 생성을 위한 통계 정보 관리의 필요성 증대. 정확한 Row Count와 데이터 분포 정보 부재 시 Join Ordering 및 Cost Estimation의 효율성 저하 발생.
Technical Solution
- gc_stats_table을 통한 테이블 단위 Tuples 수 관리로 전체적인 Cost Estimation 기준 수립
- gc_stats_column의 n_distinct 필드에 양수(절대 수치)와 음수(비율) 체계를 적용하여 Cardinality 추정 정밀도 향상
- gcluster_statistics_target 파라미터 기반의 MCV(Most Common Values) 및 Equi-height Histogram 설계로 데이터 편향성 분석
- gcluster_statistics_sampling_threshold 기준에 따른 Full Scan과 Random Sampling의 분기 처리를 통한 통계 수집 비용 최적화
- 가변 길이 타입 전용 avg_width 계산 로직을 통한 메모리 할당 및 I/O 비용 산정 최적화
실천 포인트
- gcluster_statistics_target 설정을 통한 MCV 및 Histogram Bin 개수 조정 및 데이터 분포 확인 - n_distinct의 부호 확인을 통한 Cardinality 산정 방식(절대값 vs 비율) 검토 - 대용량 테이블의 통계 갱신 주기와 Sampling Threshold 설정값의 적정성 평가