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 1vVPYy-002Rm2-1V for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Dec 2025 07:33:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVPYw-004yd8-1l for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Dec 2025 07:33:39 +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 1vVPYv-004ybN-2F for pgsql-hackers@lists.postgresql.org; Tue, 16 Dec 2025 07:33:39 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVPYt-0010SK-1L for pgsql-hackers@lists.postgresql.org; Tue, 16 Dec 2025 07:33:38 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1B1BC7A018B; Tue, 16 Dec 2025 02:33:32 -0500 (EST) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-05.internal (MEProxy); Tue, 16 Dec 2025 02:33:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1765870411; x=1765956811; bh=yWAqH9T9er LAPrlLTb7c0wcZdMjbKvaoFnKGyplco0U=; b=O5hUvJLOdKODrL9i1pwWwNVTE2 xDz7YOE55Fh/VlXzB+oDjH0x5uQn8nLQ7I3GSeJSXgA8Oue+D1bIThFbVBywFqhy PwpltGddK4aJUhkgefAT+62+axXHzriV068aDUtU91xw2aZUk7vAo2mootxaIaw8 iJb/35Iqb8ZQk/jORYXm/UBg1fztmQThVXpoBoHlYuwSIiiQv5Q6zeeCWO/SeVvD U4aaMCEANnyQI8dXm0B0nKsS21P1T8qiozGP9+wjOilnhsdpZuijoKQqwFyvOgrA vYqjSumE+9LZvxcWfDKPzuqO0OLExr/Aj5Qbfm5Vh6C0uk/B79h+UZCPsnZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1765870411; x=1765956811; bh=yWAqH9T9erLAPrlLTb7c0wcZdMjbKvaoFnK Gyplco0U=; b=Eh0COVQLYNtSN8momyDBwHaY9/j+V/gdpiflcmd9iZZUV4PsmGP T/ehm97YyNYDyahGB2rdldVW0iQ+hqp+GYQFCbtaS3CQscSeHjQwU84MiXoeg6I0 +uA0hj7jXy5rDztWkv1QraJO4tvsSCsgfjWbPXDJ4+9Subn0ah9BjkdGyRR0HEvl uTC2AHoRonwmVryeZHDY+K1R5cWTcu5rV6JdHlFXBgc2ZGxlDdFxdAC1PUOwmUjb il9rIw+iV4JBhbS3U2mvgUPWp+yLF/7SZPYx1TrTr6MmANs0woSIBjU5I+Fc1NMO mljajFlsO+mi/d7xxjui+GqjM2xV3EhgLHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefledtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrnhgurh gvshesrghnrghrrgiivghlrdguvgdprhgtphhtthhopegsvghrthhrrghnuggurhhouhhv ohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehrvghshhhkvghkihhrihhllh esghhmrghilhdrtghomhdprhgtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhl rdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhosh htghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Dec 2025 02:33:29 -0500 (EST) Date: Tue, 16 Dec 2025 16:33:17 +0900 From: Michael Paquier To: Andres Freund Cc: Bertrand Drouvot , Kirill Reshke , Robert Haas , pgsql-hackers@lists.postgresql.org Subject: Re: relfilenode statistics Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Uy3Hzvgbrximgwu8" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Uy3Hzvgbrximgwu8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 15, 2025 at 12:48:25PM -0500, Andres Freund wrote: > I don't think this is true as stated. Two reasons: >=20 > 1) This afaict guarantees that the relfilenode will not clash with oids, = but > it does *NOT* guarantee that it does not clash with other relfilenodes >=20 > 2) Note that GetNewRelFileNumber() does *NOT* check for conflicts when > creating a new relfilenode for an existing relation: > * If the relfilenumber will also be used as the relation's OID, pass the > * opened pg_class catalog, and this routine will guarantee that the resu= lt > * is also an unused OID within pg_class. If the result is to be used on= ly > * as a relfilenumber for an existing relation, pass NULL for pg_class. FWIW, I am also still troubled by the part of the proposed patch set where we are trying to hide the idea of a partitioned table has a relfilenode set by using its relid instead in the key for the data. This leads to a huge amount of complexity in the patch, mainly to store data for autovacuum that we do not need at the end: - autovacuum discards partitioned tables in do_autovacuum(), so the stats related to partitioned tables that we need to select the relations does not matter. - manual vacuums may include partitioned tables to extract its partitions, vacuum_rel() at the end discarding them. Well, stats don't matter anyway. We only need to attach three fields to let autovacuum know if a relation needs to run or not: dead_tuples, ins_since_vacuum, mod_since_analyze. Most the fields of PgStat_StatTabEntry make sense only for tables, few are required by indexes for pg_stat_all_indexes. Some fields actually make sense because they refer to on-disk files, mostly for pg_statio_all_tables (blocks_fetched, blocks_hit). Hence, why don't we split PgStat_StatTabEntry into three things from the start, even if it means to duplicate some of them? Say: - Table fields: includes [auto]vacuum/analyze data, block fields, fields of pg_stat_all_tables. - Index fields: no need for the [auto]vacuum/analyze time and counts, block fields, pg_stat_all_indexes fields. - Relfilenode fields: dead_tuples, ins_since_vacuum and mod_since_analyze. Does not apply to partitioned tables and indexes, only applies to tables. Provides a clean split, embrace the fact that these are the only three fields we need to worry about during recovery. -- Michael --Uy3Hzvgbrximgwu8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmlBCz0ACgkQnvQgOdby QH2dGQ/8D2aA2Ef4d7m/z0s7NQp4g5tjrsLuslGSAIwdrTn5Xc70lVFiCsAYJXz4 P8JPh4/35hx4PBHMHLqJ4TUYmZf1nc9kQ7HVJtp9k9zO4ycWBPmUtPOMQZbTmsGv uUximX3qUMGngtdwm+xxKqELBbYCgND8/h7J2QPjhkdhlKZRwMuy6X07Y7TUW1wA 1Zl3HNSuZ8RRaGfhsH1w7DwWXvzPSpel94ViY+Dx5adimVbOYcYqydY/7CXDSSAw xST1CajaoFIVCZsuIu9bilDgENFvrrRXUlE9rn1dYDmC3xImQpLeLJF0ZtB/bdcD 1fHeeac+7fcBT7W+loiJY5wBpQqRBJKIAoMSs2MeiSKzFA0jPqsHUmWizlbr/on9 pYJhcP+KPdd3DsaDmxZnt5gggZejrhW6xZXrE5ohOqQvPbD7+/2RCWKakWkbUiiT +OwMnys+EAgAwsiyu77GXLBaPnWGa5HxSIiJpP0Fm1faVKGCxRENEk3g1L78jK65 C6BOhiaMJ3KXypTWDBWwHJ0+AkavUJ58XbjAL/W6T4aiRoSDe2U2uF/iY4wpOaoj ttlIlwabrVo2aj8QaZyIAqgJgw+lZGd5cQs+kbeqHevT2Soeli9kHRQ6syUXhH4w 5ccgJqP3okjsC2WVog73gxL6IDYhQQwnURGl0o2Dzimgs9nnPas= =OEiZ -----END PGP SIGNATURE----- --Uy3Hzvgbrximgwu8--