본문으로 건너뛰기

log_duration

버전기본값context타입
14offsuperuserboolean
15offsuperuserboolean
16offsuperuserboolean
17offsuperuserboolean
18offsuperuserboolean
19offsuperuserboolean

완료된 모든 문장의 수행 시간을 log에 남긴다.

기본값은 off다. extended query protocol을 쓰는 클라이언트라면 Parse, Bind, Execute 단계의 시간이 각각 따로 기록된다. log_min_duration_statement를 0으로 두는 것과의 차이는 쿼리 텍스트에 있다. log_min_duration_statement는 임계값을 넘은 쿼리의 텍스트를 강제로 남기지만 log_duration은 시간만 남긴다. 그래서 log_duration = onlog_min_duration_statement를 양수로 두면 모든 문장의 duration이 기록되면서 쿼리 텍스트는 임계값을 넘은 것만 남는다. 부하가 높은 시스템에서 통계를 모을 때 유용한 조합이다.

superuser이거나 적절한 SET 권한이 있어야 바꿀 수 있다.

운영 노트: 문장마다 한 줄씩 남기 때문에 처리량이 높은 시스템에서는 log 볼륨이 급증한다. 느린 쿼리만 잡는 것이 목적이라면 log_min_duration_statement 쪽을 먼저 고려하는 편이 낫다.

출처: PostgreSQL 18 문서