public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: Jonas Gassenmeyer <[email protected]>
To: [email protected]
Subject: Re: Check explain plan of a running query in other session
Date: Mon, 08 Nov 2021 09:42:46 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CADH0_2V5NkwpqKA5GoFq_FNd01CY6zPcNam6jdvrf0H58K16-A@mail.gmail.com>
References: <CADH0_2V5NkwpqKA5GoFq_FNd01CY6zPcNam6jdvrf0H58K16-A@mail.gmail.com>

On Mon, 2021-11-08 at 09:20 +0100, Jonas Gassenmeyer wrote:
> I am asking myself for a while if there is an easy option (via dictionary views like
> pg_stat_activity or similar) to check what 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 a generic 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 session to check what the optimizer chose.
> 
> Is that something I can do easily? If not: What is the PostgreSQL way of doing it?

There is nothing like that built into PostgreSQL, but you could try pg_show_plans:
https://github.com/cybertec-postgresql/pg_show_plans

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Check explain plan of a running query in other session
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox