Rename auto_explain.sample_ratio to sample_rate

Per suggestion from Tomas Vondra

Author: Julien Rouhaud
This commit is contained in:
Magnus Hagander 2016-03-13 13:18:03 +01:00
parent a1aa8b7ea0
commit 7a8d874836
2 changed files with 11 additions and 12 deletions

View File

@ -29,7 +29,7 @@ static bool auto_explain_log_triggers = false;
static bool auto_explain_log_timing = true; static bool auto_explain_log_timing = true;
static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT; static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT;
static bool auto_explain_log_nested_statements = false; static bool auto_explain_log_nested_statements = false;
static double auto_explain_sample_ratio = 1; static double auto_explain_sample_rate = 1;
static const struct config_enum_entry format_options[] = { static const struct config_enum_entry format_options[] = {
{"text", EXPLAIN_FORMAT_TEXT, false}, {"text", EXPLAIN_FORMAT_TEXT, false},
@ -163,10 +163,10 @@ _PG_init(void)
NULL, NULL,
NULL); NULL);
DefineCustomRealVariable("auto_explain.sample_ratio", DefineCustomRealVariable("auto_explain.sample_rate",
"Fraction of queries to process.", "Fraction of queries to process.",
NULL, NULL,
&auto_explain_sample_ratio, &auto_explain_sample_rate,
1.0, 1.0,
0.0, 0.0,
1.0, 1.0,
@ -209,11 +209,11 @@ static void
explain_ExecutorStart(QueryDesc *queryDesc, int eflags) explain_ExecutorStart(QueryDesc *queryDesc, int eflags)
{ {
/* /*
* For ratio sampling, randomly choose top-level statement. Either * For rate sampling, randomly choose top-level statement. Either
* all nested statements will be explained or none will. * all nested statements will be explained or none will.
*/ */
if (auto_explain_log_min_duration >= 0 && nesting_level == 0) if (auto_explain_log_min_duration >= 0 && nesting_level == 0)
current_query_sampled = (random() < auto_explain_sample_ratio * current_query_sampled = (random() < auto_explain_sample_rate *
MAX_RANDOM_VALUE); MAX_RANDOM_VALUE);
if (auto_explain_enabled() && current_query_sampled) if (auto_explain_enabled() && current_query_sampled)

View File

@ -206,18 +206,17 @@ LOAD 'auto_explain';
<varlistentry> <varlistentry>
<term> <term>
<varname>auto_explain.sample_ratio</varname> (<type>real</type>) <varname>auto_explain.sample_rate</varname> (<type>real</type>)
<indexterm> <indexterm>
<primary><varname>auto_explain.sample_ratio</> configuration parameter</primary> <primary><varname>auto_explain.sample_rate</> configuration parameter</primary>
</indexterm> </indexterm>
</term> </term>
<listitem> <listitem>
<para> <para>
<varname>auto_explain.sample_ratio</varname> (<type>floating point</type>) <varname>auto_explain.sample_rate</varname> causes auto_explain to only
causes auto_explain to only explain a fraction of the statements in each explain a fraction of the statements in each session. The default is 1,
session. The default is 1, meaning explain all the queries. In case meaning explain all the queries. In case of nested statements, either all
of nested statements, either all will be explained or none. Only will be explained or none. Only superusers can change this setting.
superusers can change this setting.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>