Files
llm-wiki/raw/company-tech-blogs/postgresql-slow-query-logging-crunchydata.md

4.6 KiB

title, source_type, url, archive_url, status, confidence, tags, related_branches, related_projects, created, last_reviewed
title source_type url archive_url status confidence tags related_branches related_projects created last_reviewed
company-tech-blog / Logging Tips for Postgres, Featuring Your Slow Queries — Crunchy Data company-tech-blog https://www.crunchydata.com/blog/logging-tips-for-postgres-featuring-your-slow-queries raw medium
backend
db
postgresql
observability
slow-query
dba
production
feature-database-connection-pool-contract
2026-06-09 2026-06-09

Logging Tips for Postgres, Featuring Your Slow Queries — Crunchy Data

Layer: raw/ — 외부 자료(기업 기술 블로그)의 원문 발췌·출처 기록.

Parent / 활용 branch

Branch 이 자료가 정당화하는 결정
raw/branch-notes/feature-database-connection-pool-contract DB 사이드 슬로우 쿼리 탐지 방식의 실제 운영 설정과 로그 출력 형식, DBA 소유권 패턴 근거

출처 / Source

왜 저장했는지 / Why archived

feature-database-connection-pool-contract 브랜치에서 DB 사이드 슬로우 쿼리 탐지 대안 검토. Crunchy Data 는 PostgreSQL 전문 기업이며, 이 블로그는 production 에서 log_min_duration_statement 사용 패턴과 로그 출력 형식을 실제 예시와 함께 보여줌. DBA 소유권 패턴의 실제 운영 근거.

핵심 인용 / Key quotes (verbatim)

"ALTER DATABASE us SET log_min_duration_statement = '100ms';"

— 기사 본문, 데이터베이스 레벨 설정 예시

"duration: 226.904 ms statement: SELECT name, type, lon, lat FROM geonames WHERE name LIKE 'Spring%';"

— 기사 본문, PostgreSQL 슬로우 쿼리 로그 출력 예시

"Logging is expensive — logs can easily fill up your disk and waste quite a bit of your company's hard earned profits if you aren't careful."

— 기사 본문 (production 에서의 로깅 비용 경고)

Claims Extracted / 추출된 주장

Claim ID Claim (이 자료가 직접 말하는 것) Evidence quote Strength Applies to Does not prove
C1 log_min_duration_statement 는 데이터베이스 레벨로도 설정 가능하다 (ALTER DATABASE) "ALTER DATABASE us SET log_min_duration_statement = '100ms';" company-case-study PostgreSQL 12+ 앱 사이드 설정 없이 DB 레벨만으로 충분하다는 주장 반증
C2 슬로우 쿼리 로그 출력은 duration, statement 텍스트를 포함하지만 이 예시에서는 literal SQL 이 기록됨 (파라미터 바인딩 방식에 따라 다름) "duration: 226.904 ms statement: SELECT name, type, lon, lat FROM geonames WHERE name LIKE 'Spring%';" company-case-study PostgreSQL + non-parameterized query 예시 Extended query protocol 에서도 동일하게 파라미터가 마스킹된다는 주장 반증
C3 과도한 PostgreSQL 로깅은 디스크 비용과 성능에 영향을 준다 "logs can easily fill up your disk and waste quite a bit of your company's hard earned profits" company-case-study 고트래픽 production 환경 저트래픽 환경에서도 동일한 문제가 발생한다는 주장 반증

Usage Boundaries / 적용 경계

  • 이 자료가 직접 증명하는 것:
    • C1: DB 레벨 ALTER DATABASElog_min_duration_statement 설정 가능
    • C2: 실제 로그 출력 형식 (duration + statement text)
    • C3: 과도한 로깅의 production 비용 경고
  • 이 자료가 증명하지 않는 것:
    • Extended query protocol 사용 환경에서 파라미터 값이 포함/제외된다는 확정적 주장 (이 예시는 non-parameterized 쿼리)
    • 앱 사이드 탐지 방식과의 비교 우위
    • 이것이 "대기업 공식 best practice" 라는 주장 — PostgreSQL 전문 기업의 블로그이지만 일반화 불가
  • 내 프로젝트에 적용하려면 추가 확인이 필요한 것:
    • 프로젝트 PostgreSQL 환경에서 JDBC extended query protocol 사용 여부 확인 (Hibernate default: extended protocol)
    • DBA 팀의 서버 로그 접근 통제 정책 확인

메모 / Notes

  • Crunchy Data 는 PostgreSQL 전문 기업 (CrunchyDB, Crunchy Bridge 제공) — PostgreSQL 운영 실무 신뢰도 있음
  • 이 기사는 production 운영 비용(디스크/성능)의 실용적 조언을 포함 — DB 사이드 탐지의 운영 부담을 보여주는 근거