Re: auto_explain : log queries with wrong estimation

From: Adrien Nayrat <adrien(dot)nayrat(at)dalibo(dot)com>
To: Maksim Milyutin <milyutinma(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: auto_explain : log queries with wrong estimation
Date: 2017-08-28 15:46:48
Message-ID: f0c11588-f4c0-b9c3-3ed2-384c7b62cd11@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 08/24/2017 03:08 PM, Maksim Milyutin wrote:
[...]
>
> AFAICS you want to introduce two additional per-node variables:
>  - auto_explain_log_estimate_ratio that denotes minimum ratio (>= 1) between
> real value and planned one. I would add 'min' prefix before 'ratio'.
>  - auto_explain_log_estimate_min_rows - minimum absolute difference between
> those two values. IMHO this name is somewhat poor, the suffix 'min_diff_rows'
> looks better.
> If real expressions (ratio and diff) exceed these threshold values both, you log
> this situation. I'm right?

Yes, you're totaly right! I wonder if "ratio" is fine or if I should use "factor"?

[...]
>
> Instrumentation is initialized only with analyze (log_analyze is true)[1]

Good, I didn't notice instrumentation can be enabled in auto_explain's hook. I
added these lines and it works :

if (auto_explain_log_estimate_ratio || auto_explain_log_estimate_min_rows)
{
queryDesc->instrument_options |= INSTRUMENT_ROWS;
}

But I need to undestand how instrumentation works.

Thanks for your answer. I will continue my work, actually my patch is not
functionnal.

--
Adrien NAYRAT

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2017-08-28 16:23:23 Write operations in parallel mode
Previous Message Tom Lane 2017-08-28 14:47:58 Re: [HACKERS] [postgresql 10 beta3] unrecognized node type: 90