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 1vJnFn-002sum-19 for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Nov 2025 06:25:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vJnFl-004kZ2-0B for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Nov 2025 06:25:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vJnFk-004kYt-2R for pgsql-hackers@lists.postgresql.org; Fri, 14 Nov 2025 06:25:48 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1vJnFj-0073Dl-0T for pgsql-hackers@lists.postgresql.org; Fri, 14 Nov 2025 06:25:47 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 7A24EEC009A; Fri, 14 Nov 2025 01:25:46 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Fri, 14 Nov 2025 01:25:46 -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=1763101546; x=1763187946; bh=4S7vbipSvK 9sBds3cQpPkYeGr4K8qfSe+Zd0kGnA7dQ=; b=iW3Kv8VmjwOpWp5Kok9gU1vPeF WoXxEnuAK4LIO+GnI6MEcGcPQZyH3YLSjdAzJavEKZSXfIUqPx+SVRcuwhoNzEfH DF0wO78cQpMusq/V/hLb6164tKMC3nxDjalbK35j/m+ewgv9aztXZsmVLNUHWeDQ 1/eyrjLuWN+efFHcMa4zc2DFaHu2c4W2Is6YH7/YHKvPHaPftaN2xuNIzj1fWhL4 ghjflL6BwPj/8hIysAZSBKoEtG3CDIAnGcNZmNt20/IqI1jzaMrYbgb3pUFLTA7/ w6+EgYte1Fi03YeojRn6E6Zoy9LGAiKkgi9k0To9MEoEohxwyhzrf7obObCQ== 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= 1763101546; x=1763187946; bh=4S7vbipSvK9sBds3cQpPkYeGr4K8qfSe+Zd 0kGnA7dQ=; b=g4oyg/Sk2wgxOEFZ8g5m+9cTqcNdxYqbWQfyFMBTE3HgAAnVsrh sFS7Ym9UdBewSn9BScEYCJvKfRQz+astwuuCluQ0sLYlFjN2D+BfHR5uCAqN8lvZ aGK8C31d/nKrjl1l2EDEnXVrQ8x9go6afhpQyqJrepY3zHWibu5G51REo+b6jKRi Af0yl/OLXZRSZcW/kmT8lj5wlR1gbdXNrHeDHUPFOjcbx7g/1bOUZQY0/sk4xBKO vGBd27kDb4XfMSvEGp+dpXUXxS022tExsGKHzhSV5aTWRxpa8cLmfIYb0miRaHwT te7RpmZubZJMa4UrxZ9nCAAyrL7Jk7ChQyg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvtdeluddtucetufdoteggodetrf 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; Fri, 14 Nov 2025 01:25:44 -0500 (EST) Date: Fri, 14 Nov 2025 15:25:27 +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="VCBbQdVohHX4k75v" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --VCBbQdVohHX4k75v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Nov 14, 2025 at 12:49:23AM -0500, Corey Huinker wrote: > Negative numbers represent the Nth expression defined in the extended > statistics object. So if you have extended statistics on a, b, length(a), > length(b) then you can legally have -1 and -2 in the attributes, but > nothing lower than that. > > See functions pg_ndistinct_validate_items() and > pg_depdendencies_validate_deps() as these check the attributes in the value > against the definition of the extended stats object. Exactly. Extended stats on system columns don't work because they don't really make sense as we want to track correlations between the attributes defined, and these reflect internal states: create table poo (a int, b int); create statistics poos (ndistinct ) ON cmax, a from poo; ERROR: 0A000: statistics creation on system columns is not supported Note that the expressions are also stored in pg_stats_ext_exprs. > I'm trying to implement those test cases, but I may have missed some. I've found a lot of them with coverage-html during a previous lookup. I'd like to think that we should aim for something close to 100% coverage for the two input functions. > Implemented many, but not all of these suggestions. Thanks for the new versions, I'll also look at all these across the next couple of days. Probably not at 0005~ for now. -- Michael --VCBbQdVohHX4k75v Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmkWy1cACgkQnvQgOdby QH0uRQ//XBfvzo/PlKEXN59RyTz+p2rF3Q5zn5x+sH+qyYhLZkh7Z8KlkO3WoIA/ DeSdp6XZW0okCJRujGrjjN6VSAZQa0mdC9OnUoFTMKQJkQQYa3sLpRb4SSbx3uuZ AfmXoiGxsoGpSyXvhI3ymr7H53TlQoU/5pstGs1dTevdBVxYWiTcXwOy/n3fbLCn RJhYUwM5+k13NJKzHTbBU6evm2WmXQLPNJLrmvxKwmsEJtmg6FDDK6ABc99l184+ dUAm6hEXeR9T+fGUQSTrN+jOlntaKuzNmO8iCy2D8zL73smDwLO9Ea9KJxp9HNtv nv60J788OTxKQilf8TxqQdpBOYW1MmqXW7WH7JpDugQHFwJg+WpzNUJnUDDL0LvQ uzv+FcKU8wsK0YTXhNE+4yXICSMqD5X7mjQ6n5w983UqeYuBv8wn0F60gK0u/1S9 FCbufYPC3ZnnHkf9SAhHnfMBhkMY9ocFQijRDNNEon2glKLs9f6+19vadbbzFeyx uX2v+o+NHPUpL+Dot/myh74XwDR82D3CIb6TudFC/CPf+9rry5ku5z98mD110z86 KLoOGmBcr7Zfc66rqDJH69jErCIRAU++DfEzUS5jdR714/tl8vxBnMkfoYjIfEtm BdotL4bE71MRASppobDVddzWz5ADxBZcPPL3iUKZArM9JN2GZts= =8wUv -----END PGP SIGNATURE----- --VCBbQdVohHX4k75v--