Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Naga Appani <nagnrik@gmail.com>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Tomas Vondra <tomas@vondra.me>, Xuneng Zhou <xunengzhou@gmail.com>, torikoshia <torikoshia@oss.nttdata.com>, Kirill Reshke <reshkekirill@gmail.com>, pgsql-hackers@postgresql.org
Date: 2025-12-17T04:19:11Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add pg_get_multixact_stats()
- 97b101776ce2 19 (unreleased) landed
-
Add MultiXactOffsetStorageSize() to multixact_internal.h
- 0e3ad4b96aed 19 (unreleased) landed
-
Change GetMultiXactInfo() to return the next multixact offset
- 9cf746a453c1 19 (unreleased) landed
-
Widen MultiXactOffset to 64 bits
- bd8d9c9bdfa0 19 (unreleased) cited
-
Refactor ReadMultiXactCounts() into GetMultiXactInfo()
- a977e419ee6e 19 (unreleased) landed
-
Move SQL-callable code related to multixacts into its own file
- df9133fa6384 19 (unreleased) landed
-
Split func.sgml into more manageable pieces
- 4e23c9ef65ac 19 (unreleased) cited
On Sat, Dec 13, 2025 at 01:34:47PM -0600, Naga Appani wrote: > Documentation changes: > - Removed the NULL-return discussion from func-info.sgml, as the > statistics are now always available. > - Updated maintenance.sgml to clarify that exceeding the historical > 2^32 member limit no longer causes wraparound, but instead triggers > more aggressive vacuum activity for disk space management. > > I validated the behavior before and after cleanup. > The function correctly reports current usage (beyond the old limits) and > resets once multixacts are removed: + /* + * Calculate storage space for members. Members are stored in groups, + * with each group containing MULTIXACT_MEMBERS_PER_MEMBERGROUP members + * and taking MULTIXACT_MEMBERGROUP_SIZE bytes. + */ + membersBytes = (int64) (members / MULTIXACT_MEMBERS_PER_MEMBERGROUP) * + MULTIXACT_MEMBERGROUP_SIZE; This is the key point of the patch internal logic. And there is one thing that I am wondering here. The amount of space taken by a number of members depends on the other compiled constants from multixact_internal.h. Hence, rather than calculate the amount of space taken by a set of members in some code hidden in the SQL function, could it be better to put that directly as a macro or an inline function in multixact_internal.h? -- Michael