↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / Configuration Parameters

log_duration

Causes the duration of every completed statement to be logged. The default is off. Only superusers and users with the appropriate SET privilege can change this setting. For clients using extended query protocol, durations of the Parse, Bind, and Execute steps are logged independently. Note The difference between enabling log_duration and setting log_min_duration_statement to zero is that exceeding log_min_duration_statement forces the text of the query to be logged, but this option doesn't. Thus, if log_duration is on and log_min_duration_statement has a positive value, all durations are logged but the query text is included only for statements exceeding the threshold. This behavior can be useful for gathering statistics in high-load installations.

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
off
category
Reporting and Logging / What to Log
context
superuser
doc same as
Unknown
documented
true
enumvals
Unknown
extra desc
Unknown
lang
en
max val
Unknown
metadata version
18
min val
Unknown
name
log_duration
short desc
Logs the duration of each completed SQL statement.
source
pg-settings-source-snapshot
unit
Unknown
vartype
bool

Definition PG 18

Causes the duration of every completed statement to be logged. The default is off. Only superusers and users with the appropriate SET privilege can change this setting.

For clients using extended query protocol, durations of the Parse, Bind, and Execute steps are logged independently.

Note

The difference between enabling log_duration and setting log_min_duration_statement to zero is that exceeding log_min_duration_statement forces the text of the query to be logged, but this option doesn't. Thus, if log_duration is on and log_min_duration_statement has a positive value, all durations are logged but the query text is included only for statements exceeding the threshold. This behavior can be useful for gathering statistics in high-load installations.

Compare versions

Complete source facts

doc html

<p>
        Causes the duration of every completed statement to be logged.
        The default is <code class="literal">off</code>.
        Only superusers and users with the appropriate <code class="literal">SET</code>
        privilege can change this setting.
       </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>
         The difference between enabling <code class="varname">log_duration</code> and setting
         <a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT">log_min_duration_statement</a> to zero is that
         exceeding <code class="varname">log_min_duration_statement</code> forces the text of
         the query to be logged, but this option doesn't.  Thus, if
         <code class="varname">log_duration</code> is <code class="literal">on</code> and
         <code class="varname">log_min_duration_statement</code> has a positive value, all
         durations are logged but the query text is included only for
         statements exceeding the threshold.  This behavior can be useful for
         gathering statistics in high-load installations.
        </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:fee662f4632d61c7c5319f4cc9469d5a2130f2d32111343ddbea79bd87746ddc

Text language: en · wiki-repair-20261023:fee662f4632d61c7c5319f4cc9469d5a2130f2d32111343ddbea79bd87746ddc