# log_statement_stats

> log_statement_stats — Writes cumulative performance statistics to the server log. Observed in PG9.0–19 Beta 3; its last measured boot default is off in PG19 Beta 3, with superuser context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA.
---

> [!NOTE]
> **Fact — official short description:** “Writes cumulative performance statistics to the server log.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `bool` | Upstream pg_settings type |
| Context | `superuser` | Settable at runtime by a superuser |
| Unit | — | Raw unit |
| Range | — | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Statistics / Monitoring | Upstream classification |
| Latest boot value | `off` | off |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.0–19 Beta 3 | `off` | — | off |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

log_statement_stats emits whole-statement resource usage for every query using a crude getrusage-style profiler. Output goes to the server log and is intended for short diagnostic sessions.

log_statement_stats reports the total statement, while parser, planner, and executor switches report individual phases. The total switch cannot be enabled together with any per-phase switch.

This is synchronous diagnostic logging rather than the cumulative statistics system. Volume and formatting make it unsuitable as routine production telemetry. Its superuser context permits an authorized session change without a server restart.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Do not enable log_statement_stats as normal OLTP tuning. Use it briefly on an isolated reproduction or one controlled session, collect the needed log, then disable it. |
| OLAP | For a specific analytical statement, EXPLAIN (ANALYZE, BUFFERS) and cumulative views are usually more actionable than cluster-wide log_statement_stats. Scope any use and budget log volume. |
| Small nodes | Leave log_statement_stats=off. A small host is especially vulnerable to diagnostic log I/O and storage exhaustion. |
{.full-width}

## Pigsty {#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 | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 unmodified; OLAP: PG9.0–19 Beta 3 unmodified; CRIT: PG9.0–19 Beta 3 unmodified; TINY: PG9.0–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- Enabling or enlarging log_statement_stats without measuring collection and observation overhead.
- Confusing collection semantics with a performance-control or I/O-control setting.
- Assuming all statistics are immediately current inside a long transaction.
- Collecting sensitive query text or identifiers without matching access and retention policy.

## Related parameters {#related-parameters}

[`log_parser_stats`](/parameters/log-parser-stats/) · [`log_planner_stats`](/parameters/log-planner-stats/) · [`log_executor_stats`](/parameters/log-executor-stats/) · [`log_min_duration_statement`](/parameters/log-min-duration-statement/) · [`track_functions`](/parameters/track-functions/)

## References {#references}

- [PostgreSQL 19 Beta 3 — log_statement_stats](https://www.postgresql.org/docs/19/runtime-config-statistics.html#GUC-LOG-STATEMENT-STATS)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
