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 1vNKAR-00H6jL-1Q for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Nov 2025 00:10:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vNKAO-00G5jA-2K for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Nov 2025 00:10:53 +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 1vNKAO-00G5j1-1N for pgsql-hackers@lists.postgresql.org; Mon, 24 Nov 2025 00:10:52 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNKAM-0018S8-1w for pgsql-hackers@lists.postgresql.org; Mon, 24 Nov 2025 00:10:52 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 14B34EC0206; Sun, 23 Nov 2025 19:10:48 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sun, 23 Nov 2025 19:10:48 -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=1763943048; x=1764029448; bh=rkHhqqa1H1 gyYVhRcnzuWFt9g/hgSkm6dIm0Evih3dI=; b=XVzpx84n/VLfIQmr+WAE0XOHFp DrabhnWCneXXvwcmQH04lSs9BlmEBbWMC+UFHYnlKzI0Pb2TT6Th1/byVGorgy1e Xo8TCZUwJlu0LrllBMGm9i3bPaDH35hfPE1A0bzGPh9cg7IiU+mYmBy1V24WGD13 lmUlmDgJSlzK3ks24ZLaoDIbELghtPttndPMmiNJoxukZj8xDU7avCpmvUGQK4BC N+buL0ebs8W7XO+Mjewy164YSMZ7nS61557eah9TBWfkS1RLrxVMYFkj986p0tuR hlCMKh+gjjdNX6QzUihsT2t9WfIvtgnMLTV8LK3tHj+ykzXPTlSUjc272MAg== 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= 1763943048; x=1764029448; bh=rkHhqqa1H1gyYVhRcnzuWFt9g/hgSkm6dIm 0Evih3dI=; b=O/2TP267hyR7Txy0ZwmLENRvTcKwbboBiQMcHxTaoqvsXKdQN/W 9zLKg++NeJJnAawvLbjZjEg5hDTE1hJUzQ0jWGDeRBP2NM5zdiVd+PuZWnERbLmi uyInY6dDpnsFNOomBDBtFEIyIwiMU+I2gvjt1GTRf5RNKZw/dI3p0lqSsFWqIQUt 8eUkxhxDe0+aAj1+rIb3uqsEBgx2gSNL9e1hv4pUxNHGCzRnTQLk5uoSNMNNPdrk YGO8spEy0yMB6N1Opsc2Ji9T8nz4xjNs7Uw+v5laZM2e/cIDW+/2TzbOisch1HHQ JRlanZGMrYl+IF6LxP8PYcvtKF8/oJB2qWQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvfeejudefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdlfeehmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepgeffjeevgfevuddvjedtvddtieej heduueelvddufedtgfefjedvkeevkeeivddvnecuffhomhgrihhnpehpohhsthhgrhgvsh hqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopedvpd hmohguvgepshhmthhpohhuthdprhgtphhtthhopehsrghmihhmshgvihhhsehgmhgrihhl rdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhosh htghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 23 Nov 2025 19:10:46 -0500 (EST) Date: Mon, 24 Nov 2025 09:10:29 +0900 From: Michael Paquier To: Sami Imseih Cc: PostgreSQL Hackers Subject: Re: [Proposal] Adding callback support for custom statistics kinds Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="nAdqnbw1ulEdny0F" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --nAdqnbw1ulEdny0F Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 19, 2025 at 08:10:43PM -0600, Sami Imseih wrote: > It just occurred to me that the documentation [0] should be > updated to describe the callbacks. I will do that in the next > revision. >=20 > [0] https://www.postgresql.org/docs/current/xfunc-c.html#XFUNC-ADDIN-CUST= OM-CUMULATIVE-STATISTICS Hmm. Based on what I can read from the patch, you are still enforcing file name patterns in the backend, as of: + extra->statfiles[i] =3D psprintf("%s/pgstat.%d.%d.stat", + PGSTAT_STAT_PERMANENT_DIRECTORY, kind, i); My take (also mentioned upthread) is that this design should go the other way around, where modules have the possibility to define their own file names, and some of them could be generated on-the-fly when writing the files, for example for a per-file database split, or the object ID itself. The important part for variable-numbered stats is that the keys of the entries have to be in the main pgstats file. Then, the extra data is loaded back based on the data in the entry key, based on a file name that only a custom stats kind knows about (fd and file name). It means that the custom stats kind needs to track the files it has to clean up by itself in this scheme. We could pass back to the startup process some fds that it cleans up, but it feels simpler here to let the custom code do what they want, instead, rather than having an array that tracks the file names and/or their fds. -- Michael --nAdqnbw1ulEdny0F Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmkjonUACgkQnvQgOdby QH1LEA/6AqjO4fuHsEEWsMw29LQCbDfkWvl9nqIVu6UzCaQxI/upcgbWw2I/KGOf MG/0gxw+rxp3yDRxhcxGGMHtw78inHqdgVs9mz7m7cx/q2wd2fpaQCI+4sZrs8vh MB+T94c/u2za6CdhIpezKcQ7mHTvs3YwBYey7VSCd9BWkCkdGO2GuOcAWErF+2ee SOHhEelfDFkTUVLOZ9Lz7r1sUaq2qYlmni24JpH0CcWLf5piq4PEXO45+Pvc543t RyBIDp0ETupZ9XtMHmi/Mq13nWJtDpf1GSsmgYJkQ90MQ2S0cT2r1+uSG+wj9juW Yjh7DaR/yAFQkRVoOQS3jByTBwFQ/SCUO3PVzmsQ2P6sWCIpwnf46gMsOiYKrrxy +EUgohQfgCKPNJqNVze6q2fyH6HOR/+BLh6YgEBhMqu2m98ju5G41UXvAK+Gf/g3 K6F3oxg1QF4zY7yDtxwqzxdyU8zSgEK3B0xQT/Llovl+sXvBc07zLdj6yg518QDp XvZ2Z3FmEBnFefSNgG3lCHi+UfwGuVmqQBAGZSWVc0vyQ0S8sens9VhOKRJoi/95 /lui+XjmqlJr+TmG35RY82XIy/2f+nH8dYe3cEIjFSXRVoStNO6tzV8dpn7+Nu72 cPkjGJfuOMe6DcK/FavleVGF67r4KgsZWaXNaVTfi6Tep8+73zg= =Ju+Q -----END PGP SIGNATURE----- --nAdqnbw1ulEdny0F--