DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Statistics / Monitoring

log_statement_stats

Writes cumulative performance statistics to the server log.

  • Default: off
  • Type: bool
  • Applies: Session (superuser)

In plain words

After each statement, writes a block to the server log with the CPU time, memory, page faults and context switches it used, as reported by the operating system. It is a rough profiling tool and produces a lot of log output.

For DBAs and operators

Captured on 18.6 for SELECT 1:

LOG:  QUERY STATISTICS
DETAIL:  ! system usage stats:
!	0.000069 s user, 0.000000 s system, 0.000069 s elapsed
!	[0.005810 s user, 0.000000 s system total]
!	18164 kB max resident size
!	0/0 [0/16] filesystem blocks in/out
!	0/0 [0/943] page faults/reclaims, 0 [0] swaps
!	0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent
!	0/0 [7/0] voluntary/involuntary context switches

Numbers in brackets are totals for the whole process so far. The block covers the whole statement (parse + plan + execute). It cannot be combined with the per-module options:

ERROR: invalid value for parameter "log_statement_stats": 1DETAIL: Cannot enable "log_statement_stats" when "log_parser_stats", "log_planner_stats", or "log_executor_stats" is true.

Superuser-settable per session, which is the sensible way to use it. For most questions, EXPLAIN (ANALYZE, BUFFERS), track_io_timing and pg_stat_statements answer better; this is useful when you suspect OS-level effects (page faults, context switches, filesystem blocks).

How to change it

A superuser (or a role granted SET) can change it per session with SET.

See it in context

Life of a query Logger (logging collector)

Related parameters

log_parser_stats log_planner_stats log_executor_stats log_min_duration_statement

All Statistics parameters