Re: Allow auto_explain to log plans before queries are executed - Mailing list pgsql-hackers

From Julien Rouhaud
Subject Re: Allow auto_explain to log plans before queries are executed
Date
Msg-id 20200226175121.rmyait2fl2edx27v@nol
Whole thread Raw
In response to Allow auto_explain to log plans before queries are executed  (Yugo NAGATA <nagata@sraoss.co.jp>)
Responses Re: Allow auto_explain to log plans before queries are executed
List pgsql-hackers
On Thu, Feb 27, 2020 at 02:35:18AM +0900, Yugo NAGATA wrote:
> Hi,
>
> Attached is a patch for allowing auto_explain to log plans before
> queries are executed.
>
> Currently, auto_explain logs plans only after query executions,
> so if a query gets stuck its plan could not be logged. If we can
> know plans of stuck queries, we may get some hints to resolve the
> stuck. This is useful when you are testing and debugging your
> application whose queries get stuck in some situations.

Indeed that could be useful.

> This patch adds  new option log_before_query to auto_explain.

Maybe "log_before_execution" would be better?

> Setting auto_explain.log_before_query option logs all plans before
> queries are executed regardless of auto_explain.log_min_duration
> unless this is set -1 to disable logging.  If log_before_query is
> enabled, only duration time is logged after query execution as in
> the case of when both log_statement and log_min_duration_statement
> are enabled.

I'm not sure about this behavior.  The final explain plan is needed at least if
log_analyze, log_buffers or log_timing are enabled.



pgsql-hackers by date:

Previous
From: Yugo NAGATA
Date:
Subject: Allow auto_explain to log plans before queries are executed
Next
From: Vladimir Sitnikov
Date:
Subject: Re: Error on failed COMMIT