<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/all-your-gucs-in-a-row-log-min-duration-sample-log-statement-sample-rate-and-log-transaction-samp-q1podf82k" -->

---
title: All Your GUCs in a Row: log_min_duration_sample,...
description: An explanation of three lesser-known PostgreSQL logging GUCs that complement log_min_duration_statement: log_min_duration_sample and log_statement_sample_rate,...
canonical: https://daily.dev/posts/all-your-gucs-in-a-row-log-min-duration-sample-log-statement-sample-rate-and-log-transaction-samp-q1podf82k
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: All Your GUCs in a Row: log_min_duration_sample, log_statement_sample_rate, and log_transaction_sample_rate | daily.dev
og:description: An explanation of three lesser-known PostgreSQL logging GUCs that complement log_min_duration_statement: log_min_duration_sample and log_statement_sample_rate,...
og:url: https://daily.dev/posts/all-your-gucs-in-a-row-log-min-duration-sample-log-statement-sample-rate-and-log-transaction-samp-q1podf82k
og:image: https://api.daily.dev/og/posts/Q1pOdF82K.png
og:image:alt: All Your GUCs in a Row: log_min_duration_sample, log_statement_sample_rate, and log_transaction_sample_rate
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# All Your GUCs in a Row: log_min_duration_sample, log_statement_sample_rate, and log_transaction_sample_rate

**[Planet PostgreSQL](https://daily.dev/sources/planet-postgresql)** · 4 min read · 0 upvotes · 0 comments

## Summary

An explanation of three lesser-known PostgreSQL logging GUCs that complement log_min_duration_statement: log_min_duration_sample and log_statement_sample_rate, which together sample statements below the alarm threshold at a chosen rate, and log_transaction_sample_rate, which samples whole transactions rather than individual statements. It clarifies that log_min_duration_statement always takes priority regardless of sampling settings, traces the history of a PostgreSQL 12 beta feature that was reverted because it lacked this priority rule (fixed in PostgreSQL 13), and warns that log_transaction_sample_rate degenerates into statement-level sampling on autocommit workloads. The steady-state recommendation is to leave these off by default and turn them on only for targeted investigations.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://postgr.es/p/9tH>

## Questions this post answers

### Does log_statement_sample_rate override log_min_duration_statement in PostgreSQL?

No, log_min_duration_statement always takes priority. Any statement whose duration exceeds log_min_duration_statement is logged unconditionally, regardless of the sampling rate configured for log_statement_sample_rate; testing confirmed that setting log_statement_sample_rate to 0 did not suppress a 415ms query that exceeded the duration threshold.

_daily.dev surfaces practical postgres tuning writeups for engineers configuring safe log sampling._

### Why was PostgreSQL statement log sampling reverted during the 12 beta?

The original single-dial sampling design applied to statements already past log_min_duration_statement, meaning the single worst query of the day could randomly be excluded from the log, breaking the guarantee that the slowest statements always appear. The community caught this during the PostgreSQL 12 beta and reverted the feature; the corrected two-threshold version, with log_min_duration_statement taking absolute priority, shipped in PostgreSQL 13.

_track how postgres logging features evolved across versions before configuring production alarms on daily.dev._

### Why does log_transaction_sample_rate behave like statement sampling on ORM workloads?

Because a statement outside an explicit transaction is itself a transaction, so on autocommit workloads (typical of most ORM read traffic) log_transaction_sample_rate collapses into duration-blind statement sampling. In one test, 40 autocommit statements at a 0.5 sample rate produced 17 logged single-statement transactions, generating volume without the multi-statement context that makes the parameter useful.

_developers debugging orm transaction behavior can find postgres sampling nuances like this on daily.dev._

## Similar posts on daily.dev

- [All Your GUCs in a Row: log\_parser\_stats, log\_planner\_stats, log\_executor\_stats, and log\_statement\_stats](https://daily.dev/posts/all-your-gucs-in-a-row-log-parser-stats-log-planner-stats-log-executor-stats-and-log-statement-s-rfwmtvlhb) · Planet PostgreSQL · 1 upvotes · 1 comments
- [All Your GUCs in a Row: log\_checkpoints, log\_autovacuum\_min\_duration, and log\_temp\_files](https://daily.dev/posts/all-your-gucs-in-a-row-log-checkpoints-log-autovacuum-min-duration-and-log-temp-files-ou8gwpgzh) · Planet PostgreSQL · 1 upvotes · 0 comments
- [All Your GUCs in a Row: log\_min\_messages, log\_min\_error\_statement, and log\_error\_verbosity](https://daily.dev/posts/all-your-gucs-in-a-row-log-min-messages-log-min-error-statement-and-log-error-verbosity-vgxt2wbsf) · Planet PostgreSQL · 0 upvotes · 0 comments
- [All Your GUCs in a Row: log\_replication\_commands](https://daily.dev/posts/all-your-gucs-in-a-row-log-replication-commands-1amgz3vfv) · Planet PostgreSQL · 0 upvotes · 0 comments
- [All Your GUCs in a Row: log\_destination and logging\_collector](https://daily.dev/posts/all-your-gucs-in-a-row-log-destination-and-logging-collector-arg7hz5re) · Planet PostgreSQL · 1 upvotes · 1 comments

---

Tags: [#database](https://daily.dev/tags/database), [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/all-your-gucs-in-a-row-log-min-duration-sample-log-statement-sample-rate-and-log-transaction-samp-q1podf82k)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"All Your GUCs in a Row: log_min_duration_sample, log_statement_sample_rate, and log_transaction_sample_rate","url":"https://daily.dev/posts/all-your-gucs-in-a-row-log-min-duration-sample-log-statement-sample-rate-and-log-transaction-samp-q1podf82k","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/all-your-gucs-in-a-row-log-min-duration-sample-log-statement-sample-rate-and-log-transaction-samp-q1podf82k"},"datePublished":"2026-09-02T06:20:30.285Z","dateModified":"2026-09-02T06:20:53.667Z","description":"An explanation of three lesser-known PostgreSQL logging GUCs that complement log_min_duration_statement: log_min_duration_sample and log_statement_sample_rate,...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bb6b0cae7e6877a9f18e9b5c4496ca8e?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bb6b0cae7e6877a9f18e9b5c4496ca8e?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Planet PostgreSQL","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet PostgreSQL","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/planet-postgresql"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/all-your-gucs-in-a-row-log-min-duration-sample-log-statement-sample-rate-and-log-transaction-samp-q1podf82k","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"database,postgresql","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet PostgreSQL","item":"https://daily.dev/sources/planet-postgresql"},{"@type":"ListItem","position":3,"name":"All Your GUCs in a Row: log_min_duration_sample, log_statement_sample_rate, and log_transaction_sample_rate"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/all-your-gucs-in-a-row-log-min-duration-sample-log-statement-sample-rate-and-log-transaction-samp-q1podf82k#faq","mainEntity":[{"@type":"Question","name":"Does log_statement_sample_rate override log_min_duration_statement in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"No, log_min_duration_statement always takes priority. Any statement whose duration exceeds log_min_duration_statement is logged unconditionally, regardless of the sampling rate configured for log_statement_sample_rate; testing confirmed that setting log_statement_sample_rate to 0 did not suppress a 415ms query that exceeded the duration threshold. daily.dev surfaces practical postgres tuning writeups for engineers configuring safe log sampling."}},{"@type":"Question","name":"Why was PostgreSQL statement log sampling reverted during the 12 beta?","acceptedAnswer":{"@type":"Answer","text":"The original single-dial sampling design applied to statements already past log_min_duration_statement, meaning the single worst query of the day could randomly be excluded from the log, breaking the guarantee that the slowest statements always appear. The community caught this during the PostgreSQL 12 beta and reverted the feature; the corrected two-threshold version, with log_min_duration_statement taking absolute priority, shipped in PostgreSQL 13. track how postgres logging features evolved across versions before configuring production alarms on daily.dev."}},{"@type":"Question","name":"Why does log_transaction_sample_rate behave like statement sampling on ORM workloads?","acceptedAnswer":{"@type":"Answer","text":"Because a statement outside an explicit transaction is itself a transaction, so on autocommit workloads (typical of most ORM read traffic) log_transaction_sample_rate collapses into duration-blind statement sampling. In one test, 40 autocommit statements at a 0.5 sample rate produced 17 logged single-statement transactions, generating volume without the multi-statement context that makes the parameter useful. developers debugging orm transaction behavior can find postgres sampling nuances like this on daily.dev."}}]}
```

