Re: auto_explain sample rate

From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: auto_explain sample rate
Date: 2016-03-11 14:06:16
Message-ID: 56E2D0D8.2080309@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/03/16 11:45, Magnus Hagander wrote:
> On Thu, Mar 10, 2016 at 10:07 PM, Petr Jelinek <petr(at)2ndquadrant(dot)com
> <mailto:petr(at)2ndquadrant(dot)com>> wrote:
>
> On 10/03/16 20:59, Julien Rouhaud wrote:
>
> On 10/03/2016 04:37, Petr Jelinek wrote:
>
> On 17/02/16 01:17, Julien Rouhaud wrote:
>
>
> Agreed, it's too obscure. Attached v4 fixes as you said.
>
>
> Seems to be simple enough patch and works. However I would like
> documentation to say that the range is 0 to 1 and represents
> fraction of
> the queries sampled, because right now both the GUC
> description and the
> documentation say it's in percent but that's not really true
> as percent
> is 0 to 100.
>
>
> Agreed. v5 attached fixes that.
>
>
> Great, I will test it once more (just because when I don't bugs
> suddenly appear out of nowhere) and mark it ready for committer.
>
>
> Coming back to the previous discussions about random() - AFAICT this
> patch will introduce the random() call always (in explain_ExecutorStart):
>
> +if (auto_explain_log_min_duration >= 0 && nesting_level == 0)
> +current_query_sampled = (random() < auto_explain_sample_ratio *
> +MAX_RANDOM_VALUE);
>

No it doesn't as the documented way to turn off auto_explain is to set
auto_explain_log_min_duration to -1 which is also the default.

In any case the code for that would have to be something like
if (auto_explain_sample_ratio == 0)
current_query_sampled = false
else if <the original if>

Not sure if I consider that cleaner but it would definitely remove the
call to random() in case user has set auto_explain_log_min_duration to
something else than -1 and "turned off" the auto_explain by setting
auto_explain_sample_ratio to 0.

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2016-03-11 14:11:11 Re: auto_explain sample rate
Previous Message Magnus Hagander 2016-03-11 14:03:01 Re: auto_explain sample rate