Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7550619

Browse files
committed
Revert "Add log_statement_sample_rate parameter"
This reverts commit88bdbd3.As committed, statement sampling used the existing duration threshold(log_min_duration_statement) when decide which statements to sample.The issue is that even the longest statements are subject to sampling,and so may not end up logged. An improvement was proposed, introducinga second duration threshold, but it would not be backwards compatible.So we've decided to revert this feature - the separate threshold shouldbe part of the feature itself.Discussion:https://postgr.es/m/CAFj8pRDS8tQ3Wviw9%3DAvODyUciPSrGeMhJi_WPE%2BEB8%2B4gLL-Q%40mail.gmail.com
1 parent4f9ed8f commit7550619

File tree

5 files changed

+13
-65
lines changed

5 files changed

+13
-65
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5850,13 +5850,12 @@ local0.* /var/log/postgresql
58505850
<para>
58515851
Causes the duration of each completed statement to be logged
58525852
if the statement ran for at least the specified number of
5853-
milliseconds, modulated by <varname>log_statement_sample_rate</varname>.
5854-
Setting this to zero prints all statement durations.
5855-
<literal>-1</literal> (the default) disables logging statements due to
5856-
exceeding duration threshold; for example, if you set it to
5857-
<literal>250ms</literal>, then all SQL statements that run 250ms or
5858-
longer will be logged. Enabling this parameter can be helpful in
5859-
tracking down unoptimized queries in your applications.
5853+
milliseconds. Setting this to zero prints all statement durations.
5854+
Minus-one (the default) disables logging statement durations.
5855+
For example, if you set it to <literal>250ms</literal>
5856+
then all SQL statements that run 250ms or longer will be
5857+
logged. Enabling this parameter can be helpful in tracking down
5858+
unoptimized queries in your applications.
58605859
Only superusers can change this setting.
58615860
</para>
58625861

@@ -5882,27 +5881,6 @@ local0.* /var/log/postgresql
58825881
</listitem>
58835882
</varlistentry>
58845883

5885-
<varlistentry id="guc-log-statement-sample-rate" xreflabel="log_statement_sample_rate">
5886-
<term><varname>log_statement_sample_rate</varname> (<type>real</type>)
5887-
<indexterm>
5888-
<primary><varname>log_statement_sample_rate</varname> configuration parameter</primary>
5889-
</indexterm>
5890-
</term>
5891-
<listitem>
5892-
<para>
5893-
Determines the fraction of statements that exceed
5894-
<xref linkend="guc-log-min-duration-statement"/> to be logged.
5895-
The default is <literal>1.0</literal>, meaning log all such
5896-
statements.
5897-
Setting this to zero disables logging by duration, same as setting
5898-
<varname>log_min_duration_statement</varname> to
5899-
<literal>-1</literal>.
5900-
<varname>log_statement_sample_rate</varname> is helpful when the
5901-
traffic is too high to log all queries.
5902-
</para>
5903-
</listitem>
5904-
</varlistentry>
5905-
59065884
<varlistentry id="guc-log-transaction-sample-rate" xreflabel="log_transaction_sample_rate">
59075885
<term><varname>log_transaction_sample_rate</varname> (<type>real</type>)
59085886
<indexterm>

‎src/backend/tcop/postgres.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,8 +2212,7 @@ check_log_statement(List *stmt_list)
22122212

22132213
/*
22142214
* check_log_duration
2215-
*Determine whether current command's duration should be logged.
2216-
*If log_statement_sample_rate < 1.0, log only a sample.
2215+
*Determine whether current command's duration should be logged
22172216
*We also check if this statement in this transaction must be logged
22182217
*(regardless of its duration).
22192218
*
@@ -2237,7 +2236,6 @@ check_log_duration(char *msec_str, bool was_logged)
22372236
intusecs;
22382237
intmsecs;
22392238
boolexceeded;
2240-
boolin_sample;
22412239

22422240
TimestampDifference(GetCurrentStatementStartTimestamp(),
22432241
GetCurrentTimestamp(),
@@ -2254,17 +2252,7 @@ check_log_duration(char *msec_str, bool was_logged)
22542252
(secs>log_min_duration_statement /1000||
22552253
secs*1000+msecs >=log_min_duration_statement)));
22562254

2257-
/*
2258-
* Do not log if log_statement_sample_rate = 0. Log a sample if
2259-
* log_statement_sample_rate <= 1 and avoid unecessary random() call
2260-
* if log_statement_sample_rate = 1.
2261-
*/
2262-
if (exceeded)
2263-
in_sample=log_statement_sample_rate!=0&&
2264-
(log_statement_sample_rate==1||
2265-
random() <=log_statement_sample_rate*MAX_RANDOM_VALUE);
2266-
2267-
if ((exceeded&&in_sample)||log_duration||xact_is_sampled)
2255+
if (exceeded||log_duration||xact_is_sampled)
22682256
{
22692257
snprintf(msec_str,32,"%ld.%03d",
22702258
secs*1000+msecs,usecs %1000);

‎src/backend/utils/misc/guc.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ intlog_min_messages = WARNING;
511511
intclient_min_messages=NOTICE;
512512
intlog_min_duration_statement=-1;
513513
intlog_temp_files=-1;
514-
doublelog_statement_sample_rate=1.0;
515514
doublelog_xact_sample_rate=0;
516515
inttrace_recovery_messages=LOG;
517516

@@ -2705,8 +2704,7 @@ static struct config_int ConfigureNamesInt[] =
27052704
{"log_min_duration_statement",PGC_SUSET,LOGGING_WHEN,
27062705
gettext_noop("Sets the minimum execution time above which "
27072706
"statements will be logged."),
2708-
gettext_noop("Zero prints all queries, subject to log_statement_sample_rate. "
2709-
"-1 turns this feature off."),
2707+
gettext_noop("Zero prints all queries. -1 turns this feature off."),
27102708
GUC_UNIT_MS
27112709
},
27122710
&log_min_duration_statement,
@@ -3432,17 +3430,6 @@ static struct config_real ConfigureNamesReal[] =
34323430
NULL,NULL,NULL
34333431
},
34343432

3435-
{
3436-
{"log_statement_sample_rate",PGC_SUSET,LOGGING_WHEN,
3437-
gettext_noop("Fraction of statements exceeding log_min_duration_statement to be logged."),
3438-
gettext_noop("If you only want a sample, use a value between 0.0 (never "
3439-
"log) and 1.0 (always log).")
3440-
},
3441-
&log_statement_sample_rate,
3442-
1.0,0.0,1.0,
3443-
NULL,NULL,NULL
3444-
},
3445-
34463433
{
34473434
{"log_transaction_sample_rate",PGC_SUSET,LOGGING_WHEN,
34483435
gettext_noop("Set the fraction of transactions to log for new transactions."),

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,10 @@
488488
# fatal
489489
# panic (effectively off)
490490

491-
#log_min_duration_statement = -1# logs statements and their durations
492-
# according to log_statement_sample_rate. -1 is disabled,
493-
# 0 logs all statements, > 0 logs only statements running
494-
# at least this number of milliseconds.
495-
496-
#log_statement_sample_rate = 1.0# Fraction of logged statements exceeding
497-
# log_min_duration_statement to be logged.
498-
# 1.0 logs all such statements, 0.0 never logs.
491+
#log_min_duration_statement = -1# -1 is disabled, 0 logs all statements
492+
# and their durations, > 0 logs only
493+
# statements running at least this number
494+
# of milliseconds
499495

500496
#log_transaction_sample_rate = 0.0# Fraction of transactions whose statements
501497
# are logged regardless of their duration. 1.0 logs all

‎src/include/utils/guc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ extern PGDLLIMPORT int log_min_messages;
253253
externPGDLLIMPORTintclient_min_messages;
254254
externintlog_min_duration_statement;
255255
externintlog_temp_files;
256-
externdoublelog_statement_sample_rate;
257256
externdoublelog_xact_sample_rate;
258257

259258
externinttemp_file_limit;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp