Re: Add pg_stat_kind_info system view

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Tristan Partin <tristan@partin.io>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-06-30T06:42:40Z
Lists: pgsql-hackers
On Wed, Jun 24, 2026 at 05:31:12AM +0000, Bertrand Drouvot wrote:
> But header in pgstat_internal.h mentions:
> 
> "
>  * Definitions for the PostgreSQL cumulative statistics system that should
>  * only be needed by files implementing statistics support (rather than ones
>  * reporting / querying stats).
> 
> "
> 
> So it looks like that we are breaking this convention here. Maybe add helper
> function(s)?

Yeah.  Pulling pgstat_internal.h in pgstatfuncs.c is not great.  The
code acts as a barrier as the internal part and the fields data
retrieved by the functions.  A couple of alternatives I can think of:
- Put this new function in a new file under activity, named blankly
pgstat_kind.c.
- Move the necessary stuff out of pgstat_internal.h into a new header,
or just pgstat_kind.h with a !FRONTEND block.
- Use a new wrapper function that copies the data we need into an
intermediate structure.  This is just a new pgstat_get_kind_info().

Among these two, putting pg_stat_get_kind_info() into a new file feels
much better than splitting the contents of pgstat_internal.h, which is
kind of the central in-core shmem-side facility.  Using a wrapper as
of option 3 looks weird knowing the existence of the kind_info()
function.

Bertrand?  Tristan?
--
Michael

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add system view pg_stat_kind_info

  2. Introduce pluggable APIs for Cumulative Statistics