Logging & statsSuperuser · per sessiondefault -1 ms

log_min_duration_statement

Sets the minimum execution time above which all statements will be logged.

How you change it

Superuser · per session

Defaults and ranges on this page were read from pg_settings on live PostgreSQL 18.4. Treat older majors as needing their own check before you copy a value.

-1 disables logging statement durations. 0 means log all statement durations.

What this means

Logs any statement that runs at least this long (in milliseconds), with 0 logging everything and -1 disabling it. It is the single most useful setting for finding slow queries in production without a heavy extension.

When it matters

Set to a threshold like a few hundred ms in production to capture genuinely slow statements.

Default-1 ms
Range-1 – 2147483647
Typeinteger
Change scopeSuperuser · per session
CategoryLogging & stats
Check the current value
SHOW log_min_duration_statement;

Tradeoffs

  • 0 logs every statement and can flood the log on busy systems.
  • Too high a threshold hides moderately slow queries that still hurt at scale.
  • Pair with pg_stat_statements for aggregate analysis rather than log scraping alone.
PostgreSQL manual: log_min_duration_statement

Related errors

← All GUCs · Glossary · Runbooks