Re: proposal: psql: psql variable BACKEND_PID - Mailing list pgsql-hackers

From Andres Freund
Subject Re: proposal: psql: psql variable BACKEND_PID
Date
Msg-id 20230213175829.bw6accj563em6e35@awork3.anarazel.de
Whole thread Raw
In response to Re: proposal: psql: psql variable BACKEND_PID  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

On 2023-02-13 12:52:23 -0500, Tom Lane wrote:
> Andres Freund <andres@anarazel.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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: proposal: psql: psql variable BACKEND_PID
Next
From: Andres Freund
Date:
Subject: Re: Rework LogicalOutputPluginWriterUpdateProgress