Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vaPvQ-0086ys-35 for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Dec 2025 02:57:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vaPvO-0025xY-2n for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Dec 2025 02:57:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vaPvO-0025xQ-1c for pgsql-hackers@lists.postgresql.org; Tue, 30 Dec 2025 02:57:31 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vaPvM-003Ut8-0R for pgsql-hackers@postgresql.org; Tue, 30 Dec 2025 02:57:30 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b73161849e1so1854525666b.2 for ; Mon, 29 Dec 2025 18:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767063443; x=1767668243; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=o5CnF07eSKW62XpU+Vut4XDIp5P4tOEmcQgzIXFWZUM=; b=bX5Si7zZEkNDRhbGQgVU1FUqT1wAHBNrlIsHyz0XzWuPP0Nmn9ycSck/aakRGC1eRk 6kC9eGorSobkNzqn2KOVKk0vzKCbcc7BPbAgSKJBvJfGqaxWMi9Y+2VcLbqSiMbNXdIJ NC4Eg40Bzxg5hllENwUfknupGE4meq/LMcnqSZEeSGYhQSmd78JjiSpngLIF5Hy9rMCo ZdApKcpsSpYapH8LO3omngadWZbn3a3vYl2nmmGfPnpMpQqnWjpYbQQMFsS2TMCOKVJd xJgWzsn3t9ZPZev2DZ97QaoDr8P5Wuuw4QLQLhF2zVn/GDA5x5D0pFOslP7Y+8Yh29H3 FXdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767063443; x=1767668243; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=o5CnF07eSKW62XpU+Vut4XDIp5P4tOEmcQgzIXFWZUM=; b=chlJCWTT1/NL8t0r4EWM/BFg2tHsh7mICQaoATEVPVRe8v0JIComk3rBIzK0aq3DxM o/DF6x9+VPH1L7bshMeWB0bgCMRYtLKvOBqzg5pN4FWGkNVknyjibOoH8kZB4bd4Du5k Nlauw5lyZCX/4wuUA6PNvt6rc6X2EAAfhLgkJFlqrodGj6GXEAPqXh7AbDMeLlnMJPE1 3hKFQ1y5vmDduTqVYX12oXpmiueEhwCNIphcXrzhHeV/ycb9RzXe1KOjmwXqowGt82AM T7U88L7TQsipq1fBcQpQxNiWcG0/3zphsVb9VcE+5T0bri8RbMrjV+r7/B6GvHbJBMuL b4qw== X-Forwarded-Encrypted: i=1; AJvYcCVHNQ0W8Rltqek+411D8EHPf5S4mVPWCsQRpZ88MZqgDXwus1jyDm8H4Wv5lKKRPjaMZfofIJWi+wGz3u/q@postgresql.org X-Gm-Message-State: AOJu0YzUluFy0i+dqCYPrhJmYQXyJ+3jMUM8nUOjKuvsS6xjMjmdFkO6 4h4uzdoO35ryZdzHgyTDCmRw846FwgPpRlo2/rb2PjlmOOpT3dWGNSJWRMN9CnzU5mgRpi9AU/H drKw3bSZoVQ0RK/MH49X8hnRnNJODSRY= X-Gm-Gg: AY/fxX52fUCP0onFIb8LpddzUOrW7m5nranqNHjNlxqdqlUAxIJk6aPjjsrQ0AW4u0y PZkWVQLcMNCYk2B4Mq4G7yeT3Dol1Ti9WD7+Bqg1JzctNJXTrmlxN03zSXbL7dFkKPvug3Rq9Vz he2DekoRBEs64KGsSJ2LgRdEMq3Lg3UoPwgkIPWHvyRTxGNSKvb3u0kB2fqj9a4Fv/hzBI1RD/B EpaUWXPqzc8jN3INHIy3LI2hLcdIt4GdgsJAZXuPC9qd4MN4UG3rKllaoXK+Nk+EOu2hUZcERNv FYEeXbcLNgG1Kr1J84bDe/FRer8= X-Google-Smtp-Source: AGHT+IFqr2CgU0XotDfOtDMAsuxG5x/C5Bq1j7uXoPE/ko12QehpbA+LvYGH2YiIND2L501L+q2pTYHoOD1OVtcbb6o= X-Received: by 2002:a17:907:6d22:b0:b79:f965:1ce1 with SMTP id a640c23a62f3a-b803705df6bmr3440741066b.42.1767063442533; Mon, 29 Dec 2025 18:57:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Naga Appani Date: Mon, 29 Dec 2025 20:57:11 -0600 X-Gm-Features: AQt7F2qYIKm1dzoVy7146YIYp4fc-qcG34Fx433nc3Xi0MGdFYF2srMiY9MC1gU Message-ID: Subject: Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring To: Michael Paquier Cc: Ashutosh Bapat , Tomas Vondra , Xuneng Zhou , torikoshia , Kirill Reshke , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Dec 28, 2025 at 9:51=E2=80=AFPM Michael Paquier wrote: > So, here is what I have in mind, split into independent pieces: > - Remove the existing type confusion with GetMultiXactInfo(), due to > how things have always been done in MultiXactMemberFreezeThreshold(). > - Add macro MultiXactOffsetStorageSize(), to calculate the amount of > space used between two offsets. > - The main patch, with adjustments in comments, the test (no > non-ASCII characters in that, please). One thing that was really > surprising is that you did not consider ROLE_PG_READ_ALL_STATS. We > expect all the stats information to be hidden if a role is not granted > access to them, and this function should be no exception especially as > it relates to disk space usage like database or tablespace size > functions. > > Anyway, attached are all these updated pieces. The doc edits are what > I have mentioned upthread, close to what you have suggested to me > offline. > > Comments? > -- > Michael Thank you for patches, Michael! I've tested and everything works well: - All patches apply cleanly - Isolation test (multixact-stats) passes - Function correctly reports stats under heavy load Tested with significant multixact activity: ++++++++++++++++++++++++++++++++++++++++++++++ postgres=3D# \x Expanded display is on. postgres=3D# SELECT to_char(num_mxids::bigint, 'FM999,999,999,999') AS num_mxids, to_char(num_members::bigint, 'FM999,999,999,999') AS num_members, to_char(members_size::bigint, 'FM999,999,999,999') AS members_size_byte= s, pg_size_pretty(members_size) AS members_size_pretty, to_char(oldest_multixact::text::bigint, 'FM999,999,999,999') AS oldest_multixact FROM pg_get_multixact_stats(); -[ RECORD 1 ]-------+------------------ num_mxids | 235,095,556 num_members | 14,435,701,862 members_size_bytes | 72,178,509,300 members_size_pretty | 67 GB oldest_multixact | 2 ++++++++++++++++++++++++++++++++++++++++++++++ After cleanup, the function properly resets: ++++++++++++++++++++++++++++++++++++++++++++++ -[ RECORD 1 ]-------+------------- num_mxids | 0 num_members | 0 members_size_bytes | 0 members_size_pretty | 0 bytes oldest_multixact | 235,095,558 ++++++++++++++++++++++++++++++++++++++++++++++ The oldest_multixact correctly advances to reflect the cleanup. Thanks for adding the pg_read_all_stats privilege check! I think this is ready for RFC. Best regards, Naga