Tweak docs for log_statement_sample_rate

Author: Justin Pryzby, partly after a suggestion from Masahiko Sawada
Discussion: https://postgr.es/m/20190328135918.GA27808@telsasoft.com
Discussion: https://postgr.es/m/CAD21AoB9+y8N4+Fan-ne-_7J5yTybPttxeVKfwUocKp4zT1vNQ@mail.gmail.com
This commit is contained in:
Alvaro Herrera 2019-04-03 18:54:02 -03:00
parent 799e220346
commit d1f04b96b9
3 changed files with 20 additions and 18 deletions

View File

@ -5821,11 +5821,12 @@ local0.* /var/log/postgresql
Causes the duration of each completed statement to be logged Causes the duration of each completed statement to be logged
if the statement ran for at least the specified number of if the statement ran for at least the specified number of
milliseconds, modulated by <varname>log_statement_sample_rate</varname>. milliseconds, modulated by <varname>log_statement_sample_rate</varname>.
Setting this to zero prints all statement durations. Minus-one (the default) Setting this to zero prints all statement durations.
disables logging statement durations. For example, if you set it to <literal>-1</literal> (the default) disables logging statements due to
<literal>250ms</literal> then all SQL statements that run 250ms or longer exceeding duration threshold; for example, if you set it to
will be logged. Enabling this parameter can be helpful in tracking down <literal>250ms</literal>, then all SQL statements that run 250ms or
unoptimized queries in your applications. longer will be logged. Enabling this parameter can be helpful in
tracking down unoptimized queries in your applications.
Only superusers can change this setting. Only superusers can change this setting.
</para> </para>
@ -5859,14 +5860,15 @@ local0.* /var/log/postgresql
</term> </term>
<listitem> <listitem>
<para> <para>
Determines the fraction of the statements that exceed Determines the fraction of statements that exceed
<xref linkend="guc-log-min-duration-statement"/> which to log. <xref linkend="guc-log-min-duration-statement"/> to be logged.
The default is <literal>1</literal>, meaning log to all such The default is <literal>1</literal>, meaning log all such
statements. statements.
Setting this to zero disables logging, same as setting Setting this to zero disables logging by duration, same as setting
<varname>log_min_duration_statement</varname> <varname>log_min_duration_statement</varname> to
to minus-one. <varname>log_statement_sample_rate</varname> <literal>-1</literal>.
is helpful when the traffic is too high to log all queries. <varname>log_statement_sample_rate</varname> is helpful when the
traffic is too high to log all queries.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -6144,7 +6146,7 @@ local0.* /var/log/postgresql
<note> <note>
<para> <para>
The difference between setting this option and setting The difference between enabling <varname>log_duration</varname> and setting
<xref linkend="guc-log-min-duration-statement"/> to zero is that <xref linkend="guc-log-min-duration-statement"/> to zero is that
exceeding <varname>log_min_duration_statement</varname> forces the text of exceeding <varname>log_min_duration_statement</varname> forces the text of
the query to be logged, but this option doesn't. Thus, if the query to be logged, but this option doesn't. Thus, if

View File

@ -3378,8 +3378,8 @@ static struct config_real ConfigureNamesReal[] =
{ {
{"log_statement_sample_rate", PGC_SUSET, LOGGING_WHEN, {"log_statement_sample_rate", PGC_SUSET, LOGGING_WHEN,
gettext_noop("Fraction of statements over log_min_duration_statement to log."), gettext_noop("Fraction of statements exceeding log_min_duration_statement to be logged."),
gettext_noop("If you only want a sample, use a value between 0 (never " gettext_noop("If you only want a sample, use a value between 0.0 (never "
"log) and 1.0 (always log).") "log) and 1.0 (always log).")
}, },
&log_statement_sample_rate, &log_statement_sample_rate,

View File

@ -491,9 +491,9 @@
# 0 logs all statement, > 0 logs only statements running at # 0 logs all statement, > 0 logs only statements running at
# least this number of milliseconds. # least this number of milliseconds.
#log_statement_sample_rate = 1 # Fraction of logged statements over #log_statement_sample_rate = 1.0 # Fraction of logged statements exceeding
# log_min_duration_statement. 1.0 logs all statements, # log_min_duration_statement to be logged.
# 0 never logs. # 1.0 logs all such statements, 0.0 never logs.
#log_transaction_sample_rate = 0.0 # Fraction of transactions whose statements #log_transaction_sample_rate = 0.0 # Fraction of transactions whose statements
# are logged regardless of their duration. 1.0 logs all # are logged regardless of their duration. 1.0 logs all