Re: Check explain plan of a running query in other session - Mailing list pgsql-novice

From Rafia Sabih
Subject Re: Check explain plan of a running query in other session
Date
Msg-id CA+FpmFf16zXGvQB_MMVeh79Wm-gRE3AGLofVKo5qsJGzOaYOtA@mail.gmail.com
Whole thread Raw
In response to Check explain plan of a running query in other session  (Jonas Gassenmeyer <gassenmj@gmail.com>)
List pgsql-novice
On Mon, 8 Nov 2021 at 09:20, Jonas Gassenmeyer <gassenmj@gmail.com> wrote:
>
> Hello,
>
> I am asking myself for a while if there is an easy option (via dictionary views like pg_stat_activity or similar) to
checkwhat execution plan was chosen for a long running SQL statement while it is running in a different session?
 
> I have a performance problem in a plpgsql procedure that executes an update within a loop. My guess is that it chose
ageneric plan instead of bind peeking and then does not use an index.
 
>
> I am not able to proof my theory, since I don't know how to get the explain plan for it.
> For me the easiest would be to check the running statement in a different session and "hook into" the other plpgsql
sessionto check what the optimizer chose.
 
>
> Is that something I can do easily? If not: What is the PostgreSQL way of doing it?

It is for reasons like these that we at Zalando developed an extension
pg_mon (https://github.com/RafiaSabih/pg_mon),
There you can find details like what are the scan methods and joins
etc used by the query.
You can give this a try.

-- 
Regards,
Rafia Sabih



pgsql-novice by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Check explain plan of a running query in other session
Next
From: Jean Baro
Date:
Subject: Phonetic representation LENGHT for DMETAPHONE, is there a way to make it longer?