↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / Configuration Parameters

log_min_duration_sample

Allows sampling the duration of completed statements that ran for at least the specified amount of time. This produces the same kind of log entries as log_min_duration_statement, but only for a subset of the executed statements, with sample rate controlled by log_statement_sample_rate. For example, if you set it to 100ms then all SQL statements that run 100ms or longer will be considered for sampling. Enabling this parameter can be helpful when the traffic is too high to log all queries. If this value is specified without units, it is taken as milliseconds. Setting this to zero samples all statement durations. -1 (the default) disables sampling statement durations. Only superusers and users with the appropriate SET privilege can change this setting. This setting has lower priority than log_min_duration_statement, meaning that statements with durations exceeding log_min_duration_statement are not subject to sampling and are always logged. Other notes for log_min_duration_statement apply also to this setting.

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 sampling. 0 means sample all statements.
lang
en
max val
2147483647
metadata version
18
min val
-1
name
log_min_duration_sample
short desc
Sets the minimum execution time above which a sample of statements will be logged. Sampling is determined by "log_statement_sample_rate".
source
pg-settings-source-snapshot
unit
ms
vartype
integer

Definition PG 18

Allows sampling the duration of completed statements that ran for at least the specified amount of time. This produces the same kind of log entries as log_min_duration_statement, but only for a subset of the executed statements, with sample rate controlled by log_statement_sample_rate. For example, if you set it to 100ms then all SQL statements that run 100ms or longer will be considered for sampling. Enabling this parameter can be helpful when the traffic is too high to log all queries. If this value is specified without units, it is taken as milliseconds. Setting this to zero samples all statement durations. -1 (the default) disables sampling statement durations. Only superusers and users with the appropriate SET privilege can change this setting.

This setting has lower priority than log_min_duration_statement, meaning that statements with durations exceeding log_min_duration_statement are not subject to sampling and are always logged.

Other notes for log_min_duration_statement apply also to this setting.

Compare versions

Complete source facts

doc html

<p>
         Allows sampling the duration of completed statements that ran for
         at least the specified amount of time.  This produces the same
         kind of log entries as
         <a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT">log_min_duration_statement</a>, but only for a
         subset of the executed statements, with sample rate controlled by
         <a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOG-STATEMENT-SAMPLE-RATE">log_statement_sample_rate</a>.
         For example, if you set it to <code class="literal">100ms</code> then all
         SQL statements that run 100ms or longer will be considered for
         sampling.  Enabling this parameter can be helpful when the
         traffic is too high to log all queries.
         If this value is specified without units, it is taken as milliseconds.
         Setting this to zero samples all statement durations.
         <code class="literal">-1</code> (the default) disables sampling statement
         durations.
         Only superusers and users with the appropriate <code class="literal">SET</code>
         privilege can change this setting.
        </p><p>
         This setting has lower priority
         than <code class="varname">log_min_duration_statement</code>, meaning that
         statements with durations
         exceeding <code class="varname">log_min_duration_statement</code> are not
         subject to sampling and are always logged.
        </p><p>
         Other notes for <code class="varname">log_min_duration_statement</code>
         apply also to this setting.
        </p>

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:89f96d395461099cd3f406a3e4a5bff80b03b56dfcf0c0f360d4a1f0aa6e5904

Text language: en · wiki-repair-20261023:89f96d395461099cd3f406a3e4a5bff80b03b56dfcf0c0f360d4a1f0aa6e5904