log_replication_commands
Fact — official short description: “Logs each replication command.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG9.5 |
| Present in | PG9.5–19 Beta 3 |
| Removed in | No |
| Introduction commit | 4ad2a548050f — Add GUC to enable logging of replication commands. |
| Commit date | 2014-09-13 |
| Discussion | — |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG9.5–19 Beta 3 | off |
— | off |
How it works
log_replication_commands logs each replication command. It covers replication-protocol commands as well as SQL replication commands and can therefore expose replication topology and slot activity.
log_replication_commands 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_replication_commands 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_replication_commands telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline. |
| Small nodes | Keep log_replication_commands 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 | on |
different | 'on' |
| OLAP | on |
different | 'on' |
| CRIT | on |
different | 'on' |
| TINY | on |
different | 'on' |
Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.5–19 Beta 3 = on (dcs); OLAP: PG9.5–19 Beta 3 = on (dcs); CRIT: PG9.5–19 Beta 3 = on (dcs); TINY: PG9.5–19 Beta 3 = on (dcs). Advice, pending human review — Editorial inference: Replication command history supports diagnosing slots, senders, failover, and topology changes across managed clusters.
Common pitfalls
- Changing log_replication_commands 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.
- Changing log_replication_commands globally without a rollback plan and a client or operational compatibility test.
Related parameters
log_checkpoints · log_autovacuum_min_duration · log_lock_waits · log_lock_failures · log_temp_files
References
- PostgreSQL 19 Beta 3 — log_replication_commands
- PostgreSQL 19 release notes
- Machine-readable GUC export