Configuration parameter

log_statement_stats — PostgreSQL configuration parameter

Category Run-time Statistics

For each query, output performance statistics of the respective module to the server log.

At a glance

Property Value
Parameter log_statement_stats
Category Run-time Statistics
Default (see documentation)
Value type boolean (on/off)
Change scope Per-session (SET)
Available in PostgreSQL 16, 17, 18, 19 (added in 16)

What it does

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.

(Description quoted from the official PostgreSQL documentation.)

How to apply a change

Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.

Inspect the current value and source with SHOW log_statement_stats; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'log_statement_stats';.

Tuning guidance

This governs how much activity and timing data the server collects. Collecting more improves visibility in pg_stat_* views and monitoring but adds a little overhead; collecting less is cheaper but blinds your tooling. Enable the tracking your monitoring actually consumes and leave the rest at default.

Reference

PostgreSQL documentation — log_statement_stats.

Keep going

Related & next steps

Was this helpful?

← All configuration parameters