Wiki / Configuration Parameters
log_min_duration_statement
Causes the duration of each completed statement to be logged if the statement ran for at least the specified amount of time. For example, if you set it to 250ms then all SQL statements that run 250ms or longer will be logged. Enabling this parameter can be helpful in tracking down unoptimized queries in your applications. If this value is specified without units, it is taken as milliseconds. Setting this to zero prints all statement durations. -1 (the default) disables logging statement durations. Only superusers and users with the appropriate SET privilege can change this setting. This overrides log_min_duration_sample, meaning that queries with duration exceeding this setting are not subject to sampling and are always logged. For clients using extended query protocol, durations of the Parse, Bind, and Execute steps are logged independently. Note When using this option together with log_statement, the text of statements that are logged because of log_statement will not be repeated in the duration log message. If you are not using syslog, it is recommended that you log the PID or session ID using log_line_prefix so that you can link the statement message to the later duration message using the process ID or session ID.
English manual coverage begins with PostgreSQL 7.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- boot val
- -1
- category
- Reporting and Logging / When to Log
- context
- superuser
- doc same as
- Unknown
- documented
- true
- enumvals
- Unknown
- extra desc
- -1 disables logging statement durations. 0 means log all statement durations.
- lang
- en
- max val
- 2147483647
- metadata version
- 18
- min val
- -1
- name
- log_min_duration_statement
- short desc
- Sets the minimum execution time above which all statements will be logged.
- source
- pg-settings-source-snapshot
- unit
- ms
- vartype
- integer
Definition PG 18
Causes the duration of each completed statement to be logged
if the statement ran for at least the specified amount of time.
For example, if you set it to 250ms
then all SQL statements that run 250ms or longer will be
logged. Enabling this parameter can be helpful in tracking down
unoptimized queries in your applications.
If this value is specified without units, it is taken as milliseconds.
Setting this to zero prints all statement durations.
-1 (the default) disables logging statement
durations.
Only superusers and users with the appropriate SET
privilege can change this setting.
This overrides log_min_duration_sample, meaning that queries with duration exceeding this setting are not subject to sampling and are always logged.
For clients using extended query protocol, durations of the Parse, Bind, and Execute steps are logged independently.
Note
When using this option together with
log_statement,
the text of statements that are logged because of
log_statement will not be repeated in the
duration log message.
If you are not using syslog, it is recommended
that you log the PID or session ID using
log_line_prefix
so that you can link the statement message to the later
duration message using the process ID or session ID.
Compare versions
Complete source facts
doc html
<p>
Causes the duration of each completed statement to be logged
if the statement ran for at least the specified amount of time.
For example, if you set it to <code class="literal">250ms</code>
then all SQL statements that run 250ms or longer will be
logged. Enabling this parameter can be helpful in tracking down
unoptimized queries in your applications.
If this value is specified without units, it is taken as milliseconds.
Setting this to zero prints all statement durations.
<code class="literal">-1</code> (the default) disables logging statement
durations.
Only superusers and users with the appropriate <code class="literal">SET</code>
privilege can change this setting.
</p><p>
This overrides <a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOG-MIN-DURATION-SAMPLE">log_min_duration_sample</a>,
meaning that queries with duration exceeding this setting are not
subject to sampling and are always logged.
</p><p>
For clients using extended query protocol, durations of the Parse,
Bind, and Execute steps are logged independently.
</p><div class="note"><h3 class="title">Note</h3><p>
When using this option together with
<a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOG-STATEMENT">log_statement</a>,
the text of statements that are logged because of
<code class="varname">log_statement</code> will not be repeated in the
duration log message.
If you are not using <span class="application">syslog</span>, it is recommended
that you log the PID or session ID using
<a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOG-LINE-PREFIX">log_line_prefix</a>
so that you can link the statement message to the later
duration message using the process ID or session ID.
</p></div>documentation revision
{"inputs":[{"file":"runtime-config-logging.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","version":"18.7"},{"file":"runtime-config-logging.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"68c010254e1859ec0b76f06a563babd51a6c38997f1242e35e4c6b649724b1cb","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:027bf9d5182afbb85373a908444509108004d91e62e67f0e2c8a992767676edc
Text language: en · wiki-repair-20261023:027bf9d5182afbb85373a908444509108004d91e62e67f0e2c8a992767676edc