log_transaction_sample_rate
Fact — official short description: “Sets the fraction of transactions from which to log all statements.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG12 |
| Present in | PG12–19 Beta 3 |
| Removed in | No |
| Introduction commit | 799e220346f1 — Log all statements from a sample of transactions |
| Commit date | 2019-04-03 |
| Discussion | — |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG12–19 Beta 3 | 0 |
— | 0 |
How it works
log_transaction_sample_rate sets the fraction of transactions from which to log all statements. Use a value between 0.0 (never log) and 1.0 (log all statements for all transactions). A sampled transaction logs every statement, preserving transaction context but potentially creating bursts from long or chatty transactions.
log_transaction_sample_rate is a SUPERUSER-context setting. Superuser or a role granted the appropriate SET privilege can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.
It changes emitted diagnostic data rather than query semantics, but volume, sensitive content, log_line_prefix, destinations, collector throughput, and retention determine operational cost and usefulness.
Tuning advice
Advice. These are workload-specific starting points and must be validated with measurements.
| Workload | Guidance |
|---|---|
| OLTP | Tune log_transaction_sample_rate against an explicit observability question and a measured log-volume budget. Prefer selective thresholds, sampling, or role-level overrides over indiscriminate capture. |
| OLAP | Analytical jobs can justify richer log_transaction_sample_rate telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline. |
| Small nodes | Keep log_transaction_sample_rate useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency. |
Pigsty
Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.
| Template | Effective value | Versus upstream boot | Source expression |
|---|---|---|---|
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | Unmodified | — | — |
| TINY | Unmodified | — | — |
Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG12–19 Beta 3 unmodified; OLAP: PG12–19 Beta 3 unmodified; CRIT: PG12–19 Beta 3 unmodified; TINY: PG12–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.
Common pitfalls
- Changing log_transaction_sample_rate in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
- Enabling richer logging without budgeting collector throughput, storage, retention, and downstream query cost.
- Writing SQL text, bind values, identities, or host data without a redaction and access-control policy.
- Underestimating bursts when one sampled, chatty transaction causes every statement to be logged.
Related parameters
log_min_messages · log_min_error_statement · log_min_duration_statement · log_min_duration_sample · log_statement_sample_rate
References
- PostgreSQL 19 Beta 3 — log_transaction_sample_rate
- PostgreSQL 19 release notes
- Machine-readable GUC export