Re: Per backend relation statistics tracking

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Per backend relation statistics tracking
Date: 2025-08-26 21:55:09
Message-ID: CAA5RZ0u_g2QPb_JmCYdj2Gas9SWPsvczVV-FdDmfXU8PUXPpEA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > That is why I think we should be careful about naming. pg_stat_backend feels
> > very generic, but right now it only shows relation stats. Maybe we call it
> > pg_stat_backend_tables to start? Then if we later add I/O, we could have
> > pg_stat_backend_io, or for conflicts, pg_stat_backend_conflicts, etc. That way
> > we keep things more flexible, instead of trying to fit everything into
> > one view. It also helps us avoid having to rename views in the future.
> >
> > What do you think?
>
> My initial idea was to provide just a single view for "basic" counters (i.e
> things that do not need multiple lines per backend (like pg_stat_get_backend_io()
> output would need). That would mean a single view for "basic" counters and
> a set of functions for more "sophisticated" ones (like pg_stat_get_backend_io())
> that need multiple rows per backend. Having said that, we could imagine adding
> pg_stat_get_backend_wal() output to pg_stat_backend too.
>
> Thoughts?

The data that is multiple rows per backend is unique from that perspective.
The stuff we are talking about now will be one row with data aggregated up
to the PID.

I worry that a single view will grow very wide, and we will have to eventually
split it. So we may as well start thinking about having multiple views
in advance.

> Having said that, we could imagine adding
> pg_stat_get_backend_wal() output to pg_stat_backend too.

For this one, I think we should just overload the function
pg_stat_get_backend_wal,
and if a PID is not passed in, return all of them; and just create a
new view called
pg_stat_backend_wal that returns all the PIDs. sort of like how we have
pg_stat_get_activity and pg_stat_activity, etc.

Would that not be more consistent?

--
Sami

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-08-26 22:50:34 Re: Improve LWLock tranche name visibility across backends
Previous Message Jacob Champion 2025-08-26 21:44:25 Re: pgsql: oauth: Add unit tests for multiplexer handling