Re: Query plan for currently executing query? - Mailing list pgsql-general

From Rodrigo Gonzalez
Subject Re: Query plan for currently executing query?
Date
Msg-id 20130918122910.64866057@rjgonzale-laptop
Whole thread Raw
In response to Re: Query plan for currently executing query?  (Tim Kane <tim.kane@gmail.com>)
List pgsql-general
On Wed, 18 Sep 2013 16:24:16 +0100
Tim Kane <tim.kane@gmail.com> wrote:

>
>
> On 18/09/2013 14:44, "Rowan Collins" <rowan.collins@gmail.com> wrote:
>
> >
> >Running an EXPLAIN on the exact query should give you the plan. An
> >EXPLAIN ANALYZE would have to wait for the query to complete either
> >way, so you wouldn't be able to get it mid-way through a running
> >process.
> >
> >If you don't know the exact query running, then if the
> >stats_command_string config setting is on, you should be able to get
> >it by querying the pg_stat_activity view.
> >
> >The only other problem I can think of is if there are temporary
> >tables or other session-specific objects that would exist only
> >within the running process.
> >
> >Another possibility to consider (which would also show up in
> >pg_stat_activity or similar views) is that the query is waiting on
> >some kind of lock, rather than just executing slowly.
>
>
> I think the OP was hoping for a solution that would allow him to
> retrieve the query plan that was generated at execution time.  I've
> certainly wished for this type of facility in the past, in the
> scenario where a given table may have been ANALYZE in the interim -
> making it difficult to perform any useful diagnostics on the problem
> query.
>

Maybe auto-explain is the solution?

http://www.postgresql.org/docs/9.1/static/auto-explain.html


pgsql-general by date:

Previous
From: Tim Kane
Date:
Subject: Re: Query plan for currently executing query?
Next
From: Lonni J Friedman
Date:
Subject: Re: upgrade from 9.2.x to 9.3 causes significant performance degradation