※ PostgreSQL: Run-time Statistics Parameters.
※ Version: PostgreSQL 16.
안녕하세요. 듀스트림입니다.
오늘은 가볍게 런타임 통계(Run-time Statistics) 파라미터들을 알아보고 튜닝 포인트와 주의사항에 대해 알아보겠습니다.
1. track_activities
- Default: on
- description (ENG): Collects information about executing commands (queries).
- description (한글): 실행 중인 명령(쿼리)에 대한 정보를 수집합니다.
- tuning point: 일반적으로 on 권장, pg_stat_activity 뷰로 현재 쿼리 확인 가능.
- caution: 극한의 TPS 환경에서는 성능 영향 발생.
- Application Method: reload.
2. track_activity_query_size
- Default: 1kB
- description (ENG): Sets the size reserved for pg_stat_activity.query (in bytes).
- description (한글): pg_stat_activity.query에 저장되는 쿼리 문자열의 최대 크기를 설정합니다.
- tuning point: 긴 쿼리 모니터링 필요 시 2kB~4kB로 조정 가능.
- caution: 메모리 사용량 증가.
- Application Method: reload.
3. track_counts
- Default: on
- description (ENG): Collects statistics on database activity (block reads, tuples fetched, etc.).
- description (한글): 데이터베이스 활동(블록 읽기, 튜플 처리 등)에 대한 통계를 수집합니다.
- tuning point: autovacuum 및 내부 기능 활용을 위해 필수적이므로 on 유지.
- caution: off 시 pg_stat_* 뷰 정보 부족.
- Application Method: reload.
4. track_functions
- Default: none
- description (ENG): Collects function-level statistics on database activity.
- description (한글): 함수 단위로 실행 통계를 수집합니다.
- tuning point: 함수 호출 빈도 모니터링 필요 시 pl 또는 all로 조정 가능.
- caution: 오버헤드 증가 가능.
- Application Method: reload.
5. track_io_timing
- Default: off
- description (ENG): Collects timing statistics for database I/O activity.
- description (한글): 디스크 I/O 활동(읽기/쓰기)의 소요 시간을 수집합니다.
- tuning point: 디스크 병목 분석 필요 시 on으로 설정.
- caution: CPU 오버헤드 발생 가능, 상시 on보다는 문제 발생 시 한시적으로 사용.
- Application Method: reload.
6. track_wal_io_timing
- Default: off
- description (ENG): Collects timing statistics for WAL I/O activity.
- description (한글): WAL I/O(로그 기록)의 소요 시간을 수집합니다.
- tuning point: WAL 기록 지연 문제 분석 필요 시 on으로 설정.
- caution: CPU 오버헤드 발생 가능.
- Application Method: reload.
7. stats_fetch_consistency
- Default: cache
- description (ENG): Sets the consistency level when reading statistics data (cache, snapshot, none).
- description (한글): 통계 데이터를 조회할 때 일관성 보장 수준을 설정합니다.
- tuning point: 기본값 cache가 보통 적절, 필요 시 snapshot 선택 가능.
- caution: snapshot 사용 시 부하 증가.
- Application Method: reload.
뭐 사실 이 파라미터들은 대부분의 환경에서 Default 값으로 두셔도 무방합니다.
분석 요건이 있을 때만, 해당 파라미터를 on 해주시는 게 성능 면에서 조금이라도 유리합니다.
track_activity_query_size의 경우 pg_stat_activity를 활용하여 쿼리 모니터링, 분석을 하시는 경우 수치를 늘려주시면 볼 수 있는 쿼리의 길이가 늘어납니다. (단, 본문에 작성된 내용처럼 메모리 사용량이 증가하기 때문에 작은 메모리도 소중하다면 기본값 유지를 권장드립니다.)
원래 옵티마이저 관련 파라미터를 작성하려고 했는데.. 너무 많아요...
다음 포스팅에 작성해 보겠습니다 :)
오늘은 여기까지~
'PostgreSQL' 카테고리의 다른 글
PostgreSQL: 표현식 인덱스 (0) | 2025.02.19 |
---|---|
PostgreSQL: Query Planning(Optimizer) 파라미터 (0) | 2025.02.17 |
PostgreSQL: DDoS(Distributed Denial of Service) 공격 방어 (0) | 2025.02.15 |
PostgreSQL: SQL Error [40001] (0) | 2025.02.14 |
PostgreSQL: Autovacuum 최적화 (0) | 2025.02.14 |