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 1vB5Ew-00AEZn-2K for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Oct 2025 05:48:57 +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 1vB5Et-006kd2-29 for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Oct 2025 05:48:54 +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 1vB5Es-006kcu-94 for pgsql-hackers@lists.postgresql.org; Tue, 21 Oct 2025 05:48:53 +0000 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vB5Eo-003N8Q-1f for pgsql-hackers@lists.postgresql.org; Tue, 21 Oct 2025 05:48:53 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 1B3D1EC00C7; Tue, 21 Oct 2025 01:48:48 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Tue, 21 Oct 2025 01:48:48 -0400 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=fm2; t=1761025728; x=1761112128; bh=IZPam3yuLP MNSshEnG+ooXN6mlR4oRxkuXQTDUVbDYc=; b=I2eANf3v1cWS7fZ43RnPIM5fKR ZN5bJw6s/eLLDiPKs2tMr1luYS6pH8kEniEsQfxSRkM27YMpzscga/6fs2w3YBTb v4CEhqjPAMPYxlcosgDXYaLUR+VMfLLQnB21msfXHOE+Y/digoNHqJW9LVx9A7fA IQ8OGzvXLnrpfH7xDWzukqFxgQRI28iMgfQ/NIj+L6kmMsM5hOFS5DLXEvRM9nrB L+0yNhtWV8q2mrvQ7ogsOfuyGc4tz6NR9GSVre2KCdTWI2g4yUn02hd2nz1ziAU6 43b9ogekiX0XKZ26cNEFVgvKMm9BuyH+Vsw5E8rmgQ4zBYcHrqhtPA0oed+g== 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=fm2; t= 1761025728; x=1761112128; bh=IZPam3yuLPMNSshEnG+ooXN6mlR4oRxkuXQ TDUVbDYc=; b=jSynp9Q1krnzLyrkvHrAU/lkqWbHYiOfAyjm0UwgLRkK2SlSvpp A2tAqZW+Nb/jPcQwCOkPtzMEbpO7+wrap5jev/XyesRWhvpfgl9S0hbOWv46ytDE Di0OfhfZ7EtxYG4d3P9Iu0Y/YwNLEzN/U+X5GNRl5bi0MjnnZL7WqII12B+ifXtH KsqJj1BqqwNZgImGn+jWUZ6gtwz5qylmbQ38u13YXQ0DaYNVlJbQp35NQrIEIKsO S2wbX4IeVaXX7VpMR13rQaqg2cx0mVTl7JnMnxFiTwuNE8JqJpUe3yw6n2vqU/B6 N+d3kTwXQuwTy6lstRoJfM2HBZhScRxf42Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddufeelledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheptghorh gvhidrhhhuihhnkhgvrhesghhmrghilhdrtghomhdprhgtphhtthhopehjihgrnhdruhhn ihhvvghrshgrlhhithihsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhomhgrshesvh honhgurhgrrdhmvgdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhs rdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrd hprgdruhhs X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 Oct 2025 01:48:46 -0400 (EDT) Date: Tue, 21 Oct 2025 14:48:37 +0900 From: Michael Paquier To: Corey Huinker Cc: jian he , Tomas Vondra , pgsql-hackers@lists.postgresql.org, tgl@sss.pgh.pa.us Subject: Re: Extended Statistics set/restore/clear functions. Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rZpy6TawEcvbnz53" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --rZpy6TawEcvbnz53 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 18, 2025 at 08:27:58PM -0400, Corey Huinker wrote: > And rebased again to conform to 688dc6299 and 4bd919129. The format redesign for extended stats is pretty nice, as done in 0001. I think that this patch should be split in two, actually, as it tackles two issues: - One patch for the format change. - Second patch for the introduction of the input function, useful on its own to allow more regression tests paths for the format generated. Similar split comment for 0002 regarding pg_dependencies. The format change is one thing. The input function is cool to have for input validation, still not absolutely mandatory for the core part of the format change. The functions exposed in 0003 should be renamed to match more with the style of the rest, aka it is a bit hard to figure out what they do at first sight. Presumably, these should be prefixed with some "statext_", except text_to_stavalues() which could still be named the same. Do you have some numbers regarding the increase in size this generates for the catalogs? 0004 has been designed following the same model as the relation and attribute stats. That sounds OK here. +enum extended_stats_argnum [...] +enum extended_stats_exprs_element It would be nice to document why such things are around. That would be less guessing for somebody reading the code. Reusing this small sequence from your pg_dump patch, executed on a v14 backend: create schema dump_test; CREATE TABLE dump_test.has_ext_stats AS SELECT g.g AS x, g.g / 2 AS y FROM generate_series(1,100) AS g(g); CREATE STATISTICS dump_test.es1 ON x, (y % 2) FROM dump_test.has_ext_stats; ANALYZE dump_test.has_ext_stats; Then pg_dump fails: pg_dump: error: query failed: ERROR: column e.inherited does not exist LINE 2: ...hemaname =3D $1 AND e.statistics_name =3D $2 ORDER BY e.inherite= =2E.. + * TODO: Until v18 is released the master branch has a + * server_version_num of 180000. We will update this to 190000 as soon + * as the master branch updates. This part has not been updated. + Assert(item.nattributes > 0); /* TODO: elog? */ [...] + Assert(dependency->nattributes > 1); /* TODO: elog? */ Yes and yes. It seems like it should be possible to craft some input that triggers these.. +void +free_pg_dependencies(MVDependencies *dependencies); Double declaration of this routine in dependencies.c. Perhaps some of the regression tests could use some jsonb_pretty() in the outputs generated. Some of the results generated are very hard to parse, something that would become harder in the buildfarm. This comment starts with 0001 for stxdndistinct. I have mixed feelings about 0005, FWIW. I am wondering if we should not lift the needle a bit here and only support the dump of extended statistics when dealing with a backend of at least v19. This would mean that we would only get the full benefit of this feature once people upgrade to v20 or dump from a pg_dump with --statistics from at least v19, but with the long-term picture in mind this would also make the dump/restore picture of the patch dead simple (spoiler: I like simple).=20 Tomas, what is your take about the format changes and my argument about the backward requirements of pg_dump (about not dumping these stats if connecting to a server older than v18, included)? -- Michael --rZpy6TawEcvbnz53 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmj3HrUACgkQnvQgOdby QH2QwQ//eKZE2oy3lc8vmOwvwXwaJC27hoiZeClFleHSQpsbS7228GLyQN1ejnAC P4YocG3+nA8WhQPVqxYHdwWbFv8y6isBkCM54CRZUh2kUoFfsVTKPtGeAOXgQEVB Lkj+TmvCWC3PI/qGNY1jBvHxhKfLlKg5N0hUHtHF4H6sErsKEwC3ZGv4QnWJFnQC ecMGGwMNtN8VQ/ltWxPmlwxgK1TYLXbBG0UteXKydVge/4AxDAsrQNN1CcLKpbP5 3EroLScLoKVa2Nf1993rGhITJQQuxVMVMfolLevgjOwhbSRW+DXRnAYAQsCuAUv1 93+raQNIJJvq3d5ix4QzEbI0HFjxIUkXweOWv7rFIN3zWd/vWfYQYiu8iyStXf3d ArIJ/tB0y45KU0lHhLe+8ckHXCoDF1OMlJgMA4JZVPMLfrQjoxwpPbHk2jLaOn9o 1I9mpuyQwDFtCsb2HCrU0UmhWejAorm2IbBI0cO0HvRLbCao5YTyCdlBhTlvpP/p Kg22TseBEsngJX80PmR8NsJT0JNPrJqSrTVAWnSKhAH/z3tSZ/cItcUHwo0M1FvU 3hRuuUNiWxM1/ZbFe+/tjgi2YOxfU8NLn4u3ySXjUNPgzWjMycoqoRBtb+8VS4Ca +izDu2EQcr4f2DaGdLZGiHQoRbulGzUN4fnIyjoYW729pTF+qmw= =ux33 -----END PGP SIGNATURE----- --rZpy6TawEcvbnz53--