Re: proposal: psql: psql variable BACKEND_PID

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: proposal: psql: psql variable BACKEND_PID
Date: 2023-02-13 17:58:29
Message-ID: 20230213175829.bw6accj563em6e35@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-02-13 12:52:23 -0500, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > E.g. I fire of a query, it's slower than I'd like, I want to attach perf. Of
> > course I can establish a separate connection, query pg_stat_activity there,
> > and then perf. But that requires manually filtering pg_stat_activity to find
> > the query.
>
> ... in this case, the problem is that the session is tied up doing the
> slow query. You can't run "select pg_backend_pid()", but you can't
> extract a psql variable value either. If you had the foresight to
> set up a PROMPT, or to collect the PID earlier, you're good. But I'm
> still not seeing where a psql variable makes that easier.

I guess you could argue that referencing BACKEND_PID in PROMPT would be more
readable. But that's about it.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-02-13 18:00:58 Re: Rework LogicalOutputPluginWriterUpdateProgress
Previous Message Tom Lane 2023-02-13 17:52:23 Re: proposal: psql: psql variable BACKEND_PID