Hi, On Fri, Sep 4, 2026 at 8:25 PM Scott Ray <[email protected]> wrote: > > > I think having pg_xmin_horizon report similar information on > > the standby, say, the long-running transaction or long-running > > analytical query or replication slot, for example, could be a valuable > > addition and will be useful in many situations. > > I agree, and in my first message in this thread, I suggested adding > standby support in a follow-up patch.
My bad, I missed that. Thanks for clarifying. > > There seems to be some degree of information > > bloat being added by this patch. I mean, most of the columns are > > already derivable from elsewhere today. We must try to address this > > point. This may be okay given we compute things in one pass of > > proc-array/replication slots. Let's see what others have to say about > > this. > > Please explain specifically where you see information bloat. I meant the pid, database OID, database name etc. that the new view offers look like bloat, but that seems okay because we collect all of them over a single proc-array scan and having all these together in this view will avoid joins with other existing views. So, I would not call it information bloat anymore. > > 2/ pg_xmin_horizon needs to have similar checks as > > HAS_PGSTAT_PERMISSIONS for disallowing roles that are not owners of > > the sessions (unprivileged?) from unnecessarily scanning the > > proc-array. I haven't spent enough time checking whether this can > > happen with pg_read_all_stats predefined roles, but worth verifying. > > The view requires pg_read_all_stats or equivalent permissions, as I > noted in my first email, the commit message, and the view documentation. > src/test/regress/sql/xmin_horizon.sql verifies that accessing the view > without the required permissions raises an error. The SRF requires > the same. Thanks for clarifying this. The difference with pg_stat_activity is that it emits some columns like pid, database OID, database name, xid, xmin etc. that are visible to roles not owning the session (a role set in the current session without pg_read_all_stats that was not used to login) [1]. That is probably okay. I plan to review the v6 patch soon. [1] -- no pg_read_all_stats CREATE ROLE alice LOGIN; -- connect to a database as alice psql -d postgres -U alice -- shows pid, datid, datname etc. even without pg_read_all_stats SELECT * FROM pg_stat_activity; -- permission denied SELECT * FROM pg_xmin_horizon; -- Bharath Rupireddy Amazon Web Services: https://aws.amazon.com
