Re: System username in pg_stat_activity

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: System username in pg_stat_activity
Date: 2024-02-20 21:21:30
Message-ID: CABUevEy30mayT+8t3C5bBFWONx2DXFY3fqNuhKkAu1Y5QEHOCw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 16, 2024 at 9:31 PM Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>
> On Fri, Feb 16, 2024 at 9:20 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> >
> > Hi,
> >
> > On 2024-02-16 20:57:59 +0100, Magnus Hagander wrote:
> > > On Fri, Feb 16, 2024 at 8:41 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> > > > On 2024-01-10 12:46:34 +0100, Magnus Hagander wrote:
> > > > > The attached patch adds a column "authuser" to pg_stat_activity which
> > > > > contains the username of the externally authenticated user, being the
> > > > > same value as the SYSTEM_USER keyword returns in a backend.
> > > >
> > > > I continue to think that it's a bad idea to make pg_stat_activity ever wider
> > > > with columns that do not actually describe properties that change across the
> > > > course of a session. Yes, there's the argument that that ship has sailed, but
> > > > I don't think that's a good reason to continue ever further down that road.
> > > >
> > > > It's not just a usability issue, it also makes it more expensive to query
> > > > pg_stat_activity. This is of course more pronounced with textual columns than
> > > > with integer ones.
> > >
> > > That's a fair point, but I do think that has in most ways already sailed, yes.
> > >
> > > I mean, we could split it into more than one view. But adding a new
> > > view for every new thing we want to show is also not very good from
> > > either a usability or performance perspective. So where would we put
> > > it?
> >
> > I think we should group new properties that don't change over the course of a
> > session ([1]) in a new view (e.g. pg_stat_session). I don't think we need one
> > view per property, but I do think it makes sense to split information that
> > changes very frequently (like most pg_stat_activity contents) from information
> > that doesn't (like auth_method, auth_identity).
>
> That would make sense in many ways, but ends up with "other level of
> annoyances". E.g. the database name and oid don't change, but would we
> want to move those out of pg_stat_activity? Same for username? Don't
> we just end up in a grayzone about what belongs where?
>
> Also - were you envisioning just another view, or actually replacing
> the pg_stat_get_activity() part? As in where do you think the cost
> comes?

Andres -- did you spot this question in the middle or did it get lost
in the flurry of others? :)

--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2024-02-20 21:32:53 Re: System username in pg_stat_activity
Previous Message Tom Lane 2024-02-20 20:56:04 Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);