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.94.2) (envelope-from ) id 1vINf9-006bFM-6P for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Nov 2025 08:54:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vINf7-00FERF-EV for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Nov 2025 08:54:09 +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.94.2) (envelope-from ) id 1vINf6-00FER6-GT for pgsql-hackers@lists.postgresql.org; Mon, 10 Nov 2025 08:54:09 +0000 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vINf3-006wyn-1G for pgsql-hackers@lists.postgresql.org; Mon, 10 Nov 2025 08:54:08 +0000 Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id 641B91D0008B; Mon, 10 Nov 2025 03:54:02 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Mon, 10 Nov 2025 03:54:02 -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=fm3; t=1762764842; x=1762851242; bh=438PiY8PHr NmsnNnXBC1jpSdBNewHvpJv2JwzhszAnE=; b=NuJkkbsESUaxktN96z0XSXFwwm sm4PY1esXMBOHd8AIHRa/uIkftUAP6QxJfUvl1jjI5yFU02TOmbq3csR8YB0tJWI FyiQM6pCBnrOQ6vGacGSD+TZDb/EmQng+Mur4OQLMbKBYEqt5fZUBeHTTezvVthi DlGL/GvcujRm45skGXIYllSJELsLNyX46w42RsNVldED2EKfWawUm62rfSAshjih Bc2oLY7s9N/uOu0KgQG5ezWL0HPsAwyJInWV2UmbvIowSpMHaDyCcK4BNVtSFXVa 4jORANmc4TDInQrSraAbIdFLRcDZiayiYcP+q4x4pOiIvj64XfZ+ylOOVORQ== 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=fm3; t= 1762764842; x=1762851242; bh=438PiY8PHrNmsnNnXBC1jpSdBNewHvpJv2J wzhszAnE=; b=O/+IcFKCpYhA/DlKMwsutRpg9XehIZLL+5HkWOw2XFyNboYQhIR SQWs6EMgpGPx2VyyIeLlkn5zmPlb9JhtLhJf7Vfb6y33lIfmIZw9wdwj8AOGGXQr BeyXg+Snf6l3qrSEaaf0LDgbZgwbsnUzi/ArUvPbVeFnmTtTj4ix693Hg1MVLEXs QlD43CCpzPrsjPpUNj5FBVyQMINUsY5NDnQSUAe6oLnt4zuakxFaWGASqBPOJ9+t ypi6ZYjekc3kzLZVbxHz0eEtU7lmHBcE+OdmVVXIWp1e96Q710w7UuaTetQ5sNJ0 ZYshVDVNdN2LVoPs+LFLFoEIvrxoEonxf9g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduleejkeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdlfeehmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtdorredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepueehjeefleeigfelheetveegvddv fedtveejveelleetgeekteeukeetgefgveeunecuffhomhgrihhnpehpohhsthhgrhgvsh hqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopeegpd hmohguvgepshhmthhpohhuthdprhgtphhtthhopegsvghrthhrrghnuggurhhouhhvohht rdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehrvghshhhkvghkihhrihhllhesgh hmrghilhdrtghomhdprhgtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgt ohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtgh hrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Nov 2025 03:53:58 -0500 (EST) Date: Mon, 10 Nov 2025 17:53:45 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: 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="Xja6Q1McOKyKvRuw" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Xja6Q1McOKyKvRuw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 09, 2025 at 08:33:54AM +0900, Michael Paquier wrote: > Looking at this part of the patch set for now, not looked at the rest > yet. This new stats_1.out is 2k lines long, introduced for the tests > related to rewrites as an effect of 2PC. It seems to me that a split=20 > into a new stats_rewrite would be justified for this case, to reduce > the output duplication. The first patch had an issue with some of the tests checking for dead tuples: if an autovacuum kicks in before querying the stats, we would get a dead tuple number of 0. So I have expanded the tests a bit to avoid autovacuum interactions, which should be enough to avoid noise, did a split into a new file, which should also be fine because we don't rely on a system-wide stats reset, then applied the result. The patch is spending a great deal of effort on three fronts: - making sure that the statistics are copied over after a relation rewrite. - making sure that we assign a "correct" object ID, assigning the fields of RelFileLocator based on a relation ID. Mapped and shared relations make the exercise a bit more difficult. It would be nice to avoid this kind of duplication with other code paths that assign a RelFileLocator. - Partitioned tables, where we don't have a relfilenode but we need to track statistics. The patch relies on the relation oid to assign a key, as far as I've read. Among the three points, the first one is the most invasive in the patch, it seems, and do we actually want to keep the stats across rewrites at all? The main reason of doing the relfilenode move=20 would be to rebuild these stats on a WAL-record basis because the relfile locator is the only thing we know in the startup process, and once rewritten the state of the data is different. relation_needs_vacanalyze() then cares about three fields: - Number of dead tuples, which would be 0 after a rewrite. - ins_since_vacuum, which would be 0 after a rewrite. - mod_since_analyze, for analyze, again 0. I have not checked the recent autovacuum scheduling thread to see if this set changes there. Are these numbers worth the effort of copying over at the end? Was this particular point discussed? I've seen this mentioned once here, but I am wondering what are the arguments in favor of copying the stats data versus not copying it across rewrites: https://www.postgresql.org/message-id/20240607031736.7izmr2yirznvidka%40awo= rk3.anarazel.de -- Michael --Xja6Q1McOKyKvRuw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmkRqBkACgkQnvQgOdby QH3Ynw//VweH3wWmgaSED2PtB5eQc/68YO6gNrJbUPCQzw+RBuluujKZNyeRpSvE +1e6+HMXku6mcRzIumQge2Ds8whkit3rQFiYPDs15hweOPkIQjxkkt+xm12fiClD rItTo+Qn8wujMZuextyvi5IJyZ+DtdLGnqQuofhIfOemkx6Gges96lxnR4UyrJi3 ehaC821ouMYoBaW5GaSc/wQLvlr9qD/HJaJlcPEXUeDyxWbSKVQLPmHm9WzZAxEi +RPByI5Uv7Mus7mw0aYMNSbY8GjTEiLSbSb6yQMGrHV0ypZfMcX6VcpKXCAL+cOi CJHEeExGek1eIf7jffrDu9iSEAuTLP+Oc5uiA8U7oWXhLmNoQKaNOFwkfnsgjLcW 83lBG0pKsLzO5Rk/Ms2AO1KFAp7Umgi2k6maTgCAT6tPEgLdD5VresrH7Tw9dshQ SzzEDOB6AVaoZclBnD2AzrxNPOUC7fDLa2zm3YPoH6v1Vi8/1wn8cWa4fV2CnJiA bM+cMp0FfFTOvmaZI6NUi4Uy8wYIOHCRzY+/QbhqfwjKvDihWNPUyKoNH+tqzaN+ HszhYeEaR8WUqDz3iVT8Pmt0LMgHlaixeDLOoZprY2fZCpmizuHe/GZv2COrdxY9 Gjx5lHojrIs8BOKrjjQOS7tiRoAteDMDxHDgpj8tyBEDdPNiZek= =QCGd -----END PGP SIGNATURE----- --Xja6Q1McOKyKvRuw--