Log statements running at least this long.
At a glance
| Property | Value |
|---|---|
| Parameter | log_min_duration_statement |
| Category | Logging |
| Default | -1 |
| Value type | time (ms/s/min) |
| Change scope | Per-session (SET) |
What it does
Logs each completed statement whose duration meets or exceeds this threshold (with parameters). -1 disables, 0 logs everything.
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_min_duration_statement; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'log_min_duration_statement';.
Tuning guidance
Set to a value like 250ms-1s to catch slow queries without flooding logs. This is the foundation of slow-query analysis (feed into pgBadger / auto_explain).