]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add pg_get_multixact_stats()
authorMichael Paquier <michael@paquier.xyz>
Tue, 30 Dec 2025 06:38:50 +0000 (15:38 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 30 Dec 2025 06:38:50 +0000 (15:38 +0900)
commit97b101776ce23dd6c4abbdae213806bc24ed6133
treeb60250cf0edc48a65801c4f7b985be532e78a85b
parent0e3ad4b96aedee57fc2694e28486fe0ceca8110a
Add pg_get_multixact_stats()

This new function exposes at SQL level some information related to
multixacts, not available until now.  This data is useful for monitoring
purposes, especially for workloads that make a heavy use of multixacts:
- num_mxids, number of MultiXact IDs in use.
- num_members, number of member entries in use.
- members_size, bytes used by num_members in pg_multixact/members/.
- oldest_multixact: oldest MultiXact still needed.

This patch has been originally proposed when MultiXactOffset was still
32 bits, to monitor wraparound.  This part is not relevant anymore since
bd8d9c9bdfa0 that has widen MultiXactOffset to 64 bits.  The monitoring
of disk space usage for the members is still relevant.

Some tests are added to check this function, in the shape of one
isolation test with concurrent transactions that take a ROW SHARE lock,
and some SQL tests for pg_read_all_stats.  Some documentation is added
to explain some patterns that can come from the information provided by
the function.

Bump catalog version.

Author: Naga Appani <nagnrik@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Atsushi Torikoshi <torikoshia@oss.nttdata.com>
Discussion: https://postgr.es/m/CA+QeY+AAsYK6WvBW4qYzHz4bahHycDAY_q5ECmHkEV_eB9ckzg@mail.gmail.com
doc/src/sgml/func/func-info.sgml
doc/src/sgml/maintenance.sgml
src/backend/utils/adt/multixactfuncs.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/test/isolation/expected/multixact-stats.out [new file with mode: 0644]
src/test/isolation/isolation_schedule
src/test/isolation/specs/multixact-stats.spec [new file with mode: 0644]
src/test/regress/expected/misc_functions.out
src/test/regress/sql/misc_functions.sql