# fems-timescaledb/postgresql.conf

# Connection Settings
port = 5433                             # 기본 포트를 5442으로 변경
listen_addresses = '*'                  # 모든 IP에서 접속 허용
max_connections = 100                   # 최대 동시 연결 수
superuser_reserved_connections = 3

# Shared Preload Libraries
shared_preload_libraries = 'timescaledb' # TimescaleDB 활성화

# Memory Settings
shared_buffers = '256MB'               # PostgreSQL 전용 공유 메모리
work_mem = '16MB'                      # 작업 메모리
maintenance_work_mem = '64MB'          # 유지보수 작업 메모리
effective_cache_size = '1GB'           # 시스템 캐시 예상 크기

# Write Ahead Log Settings
wal_level = 'replica'                  # WAL 레벨
max_wal_size = '1GB'                   # 최대 WAL 크기
min_wal_size = '80MB'                  # 최소 WAL 크기
checkpoint_completion_target = 0.9
wal_buffers = '16MB'

# TimescaleDB Settings
timescaledb.telemetry_level = 'off'    # 텔레메트리 비활성화
timescaledb.max_background_workers = 8  # 백그라운드 워커 수

# Query Tuning
random_page_cost = 1.1
effective_io_concurrency = 200

# Logging Settings
log_destination = 'stderr'
logging_collector = on
log_directory = 'log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_min_duration_statement = 1000
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
log_autovacuum_min_duration = 0
log_line_prefix = '%m [%p] %q%u@%d '

# Autovacuum Settings
autovacuum = on
autovacuum_max_workers = 3
autovacuum_naptime = '1min'
autovacuum_vacuum_scale_factor = 0.2

# Locale and Encoding 부분 수정
datestyle = 'iso, ymd'
timezone = 'Asia/Seoul'
lc_messages = 'C'           # 변경
lc_monetary = 'C'           # 변경
lc_numeric = 'C'           # 변경
lc_time = 'C'              # 변경