Skip to content

Commit c8e8b2f

Browse files
committed
Marginal comments and docs cleanup.
Fix up some imprecise comments and poor markup from ba79cb5. Also try to convert the documentation of log_min_duration_sample and friends into passable English.
1 parent d1e241c commit c8e8b2f

File tree

3 files changed

+49
-61
lines changed

3 files changed

+49
-61
lines changed

doc/src/sgml/config.sgml

+42-55
Original file line numberDiff line numberDiff line change
@@ -5984,13 +5984,13 @@ local0.* /var/log/postgresql
59845984
<para>
59855985
Causes the duration of each completed statement to be logged
59865986
if the statement ran for at least the specified amount of time.
5987-
If this value is specified without units, it is taken as milliseconds.
5988-
Setting this to zero prints all statement durations.
5989-
Minus-one (the default) disables logging statement durations.
59905987
For example, if you set it to <literal>250ms</literal>
59915988
then all SQL statements that run 250ms or longer will be
59925989
logged. Enabling this parameter can be helpful in tracking down
59935990
unoptimized queries in your applications.
5991+
If this value is specified without units, it is taken as milliseconds.
5992+
Setting this to zero prints all statement durations.
5993+
Minus-one (the default) disables logging statement durations.
59945994
Only superusers can change this setting.
59955995
</para>
59965996

@@ -6030,93 +6030,80 @@ local0.* /var/log/postgresql
60306030
</term>
60316031
<listitem>
60326032
<para>
6033-
Allows to sample the logging of the duration of each completed
6034-
statement if the statement ran for at least the specified amount of
6035-
time. If this value is specified without units, it is taken as milliseconds.
6033+
Allows sampling the duration of completed statements that ran for
6034+
at least the specified amount of time. This produces the same
6035+
kind of log entries as
6036+
<xref linkend="guc-log-min-duration-statement"/>, but only for a
6037+
subset of the executed statements, with sample rate controlled by
6038+
<xref linkend="guc-log-statement-sample-rate"/>.
6039+
For example, if you set it to <literal>100ms</literal> then all
6040+
SQL statements that run 100ms or longer will be considered for
6041+
sampling. Enabling this parameter can be helpful when the
6042+
traffic is too high to log all queries.
6043+
If this value is specified without units, it is taken as milliseconds.
60366044
Setting this to zero samples all statement durations.
60376045
Minus-one (the default) disables sampling statement durations.
6038-
For example, if you set it to <literal>250ms</literal>
6039-
then all SQL statements that run 250ms or longer will be considered
6040-
for sampling, with sample rate is controlled by <xref linkend="guc-log-statement-sample-rate"/>.
6041-
Enabling this parameter can be helpful when the traffic too high to
6042-
sample all queries.
60436046
Only superusers can change this setting.
60446047
</para>
60456048

60466049
<para>
6047-
This option has lower priority than <xref linkend="guc-log-min-duration-statement"/>,
6048-
meaning that statements with durations exceeding <xref linkend="guc-log-min-duration-statement"/>
6049-
are not subject to sampling and are always logged.
6050-
</para>
6051-
6052-
<para>
6053-
For clients using extended query protocol, durations of the Parse,
6054-
Bind, and Execute steps are logged independently.
6050+
This setting has lower priority
6051+
than <varname>log_min_duration_statement</varname>, meaning that
6052+
statements with durations
6053+
exceeding <varname>log_min_duration_statement</varname> are not
6054+
subject to sampling and are always logged.
60556055
</para>
60566056

6057-
<note>
60586057
<para>
6059-
When using this option together with
6060-
<xref linkend="guc-log-statement"/>,
6061-
the text of statements that are logged because of
6062-
<varname>log_statement</varname> will not be repeated in the
6063-
duration log message.
6064-
If you are not using <application>syslog</application>, it is recommended
6065-
that you log the PID or session ID using
6066-
<xref linkend="guc-log-line-prefix"/>
6067-
so that you can link the statement message to the later
6068-
duration message using the process ID or session ID.
6058+
Other notes for <varname>log_min_duration_statement</varname>
6059+
apply also to this setting.
60696060
</para>
6070-
</note>
60716061
</listitem>
60726062
</varlistentry>
60736063

60746064
<varlistentry id="guc-log-statement-sample-rate" xreflabel="log_statement_sample_rate">
6075-
<term><varname>log_statement_sample_rate</varname> (<type>real</type>)
6065+
<term><varname>log_statement_sample_rate</varname> (<type>floating point</type>)
60766066
<indexterm>
60776067
<primary><varname>log_statement_sample_rate</varname> configuration parameter</primary>
60786068
</indexterm>
60796069
</term>
60806070
<listitem>
60816071
<para>
60826072
Determines the fraction of statements with duration exceeding
6083-
<xref linkend="guc-log-min-duration-sample"/> to be logged.
6084-
This is a statistical parameter, for example <literal>0.5</literal>
6085-
means there is statistically one in two chances to log the statement.
6086-
The default is <literal>1.0</literal>, meaning log all such
6073+
<xref linkend="guc-log-min-duration-sample"/> that will be logged.
6074+
Sampling is stochastic, for example <literal>0.5</literal> means
6075+
there is statistically one chance in two that any given statement
6076+
will be logged.
6077+
The default is <literal>1.0</literal>, meaning to log all sampled
60876078
statements.
6088-
Setting this to zero disables sampling logging, same as setting
6079+
Setting this to zero disables sampled statement-duration logging,
6080+
the same as setting
60896081
<varname>log_min_duration_sample</varname> to
60906082
<literal>-1</literal>.
6091-
<varname>log_statement_sample_rate</varname> is helpful when the
6092-
traffic is too high to log all queries.
60936083
Only superusers can change this setting.
60946084
</para>
6095-
<note>
6096-
<para>
6097-
Like all statement-logging options, this option can add significant
6098-
overhead.
6099-
</para>
6100-
</note>
61016085
</listitem>
61026086
</varlistentry>
61036087

61046088
<varlistentry id="guc-log-transaction-sample-rate" xreflabel="log_transaction_sample_rate">
6105-
<term><varname>log_transaction_sample_rate</varname> (<type>real</type>)
6089+
<term><varname>log_transaction_sample_rate</varname> (<type>floating point</type>)
61066090
<indexterm>
61076091
<primary><varname>log_transaction_sample_rate</varname> configuration parameter</primary>
61086092
</indexterm>
61096093
</term>
61106094
<listitem>
61116095
<para>
6112-
Set the fraction of transactions whose statements are all logged,
6096+
Sets the fraction of transactions whose statements are all logged,
61136097
in addition to statements logged for other reasons. It applies to
61146098
each new transaction regardless of its statements' durations.
6115-
The default is <literal>0</literal>, meaning not to log statements
6116-
from any additional transaction. Setting this to <literal>1</literal>
6117-
logs all statements for all transactions.
6118-
<varname>log_transaction_sample_rate</varname> is helpful to track a
6119-
sample of transaction.
6099+
Sampling is stochastic, for example <literal>0.1</literal> means
6100+
there is statistically one chance in ten that any given transaction
6101+
will be logged.
6102+
<varname>log_transaction_sample_rate</varname> can be helpful to
6103+
construct a sample of transactions.
6104+
The default is <literal>0</literal>, meaning not to log
6105+
statements from any additional transactions. Setting this
6106+
to <literal>1</literal> logs all statements of all transactions.
61206107
Only superusers can change this setting.
61216108
</para>
61226109
<note>
@@ -6632,9 +6619,9 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
66326619
<para>
66336620
Controls whether bind parameters are logged when a statement is logged
66346621
as a result of <xref linkend="guc-log-min-error-statement"/>.
6635-
It adds some overhead, as postgres will compute and store textual
6636-
representations of parameter values in memory for all statements,
6637-
even if they eventually do not get logged.
6622+
It adds some overhead, as <productname>PostgreSQL</productname> will
6623+
compute and store textual representations of parameter values in
6624+
memory for all statements, even if they eventually do not get logged.
66386625
This setting has no effect on statements logged due to
66396626
<xref linkend="guc-log-min-duration-statement"/> or
66406627
<xref linkend="guc-log-statement"/> settings, as they are always logged

src/backend/nodes/params.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,16 @@ RestoreParamList(char **start_address)
262262

263263
/*
264264
* BuildParamLogString
265-
* Return a string that represent the parameter list, for logging.
265+
* Return a string that represents the parameter list, for logging.
266266
*
267267
* If caller already knows textual representations for some parameters, it can
268268
* pass an array of exactly params->numParams values as knownTextValues, which
269269
* can contain NULLs for any unknown individual values. NULL can be given if
270270
* no parameters are known.
271271
*
272-
* If maxlen is not zero, that's the maximum number of characters of the
273-
* input string printed; an ellipsis is added if more characters exist.
274-
* (Added quotes are not considered.)
272+
* If maxlen is not zero, that's the maximum number of bytes of any one
273+
* parameter value to be printed; an ellipsis is added if the string is
274+
* longer. (Added quotes are not considered in this calculation.)
275275
*/
276276
char *
277277
BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen)
@@ -282,7 +282,8 @@ BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen)
282282

283283
/*
284284
* NB: think not of returning params->paramValuesStr! It may have been
285-
* generated with a different maxlen, and so unsuitable.
285+
* generated with a different maxlen, and so be unsuitable. Besides that,
286+
* this is the function used to create that string.
286287
*/
287288

288289
/*

src/backend/utils/mb/stringinfo_mb.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/*
2727
* appendStringInfoStringQuoted
2828
*
29-
* Append up to maxlen characters from s to str, or the whole input string if
29+
* Append up to maxlen bytes from s to str, or the whole input string if
3030
* maxlen <= 0, adding single quotes around it and doubling all single quotes.
3131
* Add an ellipsis if the copy is incomplete.
3232
*/

0 commit comments

Comments
 (0)