Re: WAL-logging facility for pgstats kinds

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Andres Freund <andres@anarazel.de>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>, lukas@fittl.com
Date: 2025-01-09T04:53:48Z
Lists: pgsql-hackers
On Thu, Jan 02, 2025 at 08:08:42PM -0500, Andres Freund wrote:
> I can't think of a real case where we would want to WAL log the stats
> themselves, rather than re-emitting stats during replay based on the WAL
> record of the "underlying object".
> 
> Do you have counter-examples?

I'm not sure if the rebuild based on the WAL records is simpler than
logging a snapshot of them that the startup process could digest.

Anyway, I've also wanted to be able to replicate stats for historical
tracking for stats logged through hooks, and a second case was
injection point stats.  All these would require registering a custom
rmgr on top of a custom stats kind, and centralizing the logic eases a
lot some of the sanity checks they'd require as the redo callback of a
stats kind can just be attached to its PgStat_KindInfo.

I know that Lucas has been playing a bit with the area, and perhaps
he has more cases in mind where the replication of stats data could be
relevant.  So I am adding him in CC.  Perhaps I could be wrong, of
course.
--
Michael

Commits

  1. Move information about pgstats kinds into its own header pgstat_kind.h