log_statement_stats
Read PG 18 manual ↗For each query, output performance statistics of the respective module to the server log.
- Type
- bool
- Context
- superuser
- Measured default
- off
- Unit
- —
- Metadata snapshot
- 18
Definition PG 18 manual
For each query, output performance statistics of the respective module to the server log. This is a crude profiling instrument, similar to the Unix getrusage() operating system facility. log_statement_stats reports total statement statistics, while the others report per-module statistics. log_statement_stats cannot be enabled together with any of the per-module options. All of these options are disabled by default. Only superusers and users with the appropriate SET privilege can change these settings.
Measured default history
| Version interval | Default |
|---|---|
| 9.0 – 19 | off |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
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.
Operational considerations
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.
Workload guidance
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.
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.
SMALL: Leave log_statement_stats=off. A small host is especially vulnerable to diagnostic log I/O and storage exhaustion.
Version history 1
- PG 14 → 15changed
Related entries
Further reading
Definition snapshot: english-manuals:58b54de21c80774549d0cad1270… · English manual source