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 1v0gjS-00H1GD-C4 for pgsql-performance@arkaria.postgresql.org; Mon, 22 Sep 2025 13:37:30 +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 1v0gjQ-000gLv-Nn for pgsql-performance@arkaria.postgresql.org; Mon, 22 Sep 2025 13:37:28 +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.94.2) (envelope-from ) id 1v0gjQ-000gLm-Dh for pgsql-performance@lists.postgresql.org; Mon, 22 Sep 2025 13:37:28 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v0gjO-001m2J-0K for pgsql-performance@lists.postgresql.org; Mon, 22 Sep 2025 13:37:27 +0000 Received: from [192.168.1.11] (5-49-10-71.hfc.dyn.abo.bbox.fr [5.49.10.71]) by mail.dalibo.com (Postfix) with ESMTPSA id 705DF27BC6; Mon, 22 Sep 2025 15:37:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1758548244; bh=3z/V3Aq6O6AUKKv5oOnB1GYp3pk5wlU+bjhkh5lKH2c=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=LvdX72b7AGKqUHG1xWSIa6TGmsBUjptC4M+PA8MgC1oSB0wNKsxuDQi4fgmmbo2d4 uCz5B/BLCTsSKV/sMR0rBbV+gMJZvtI1RCldI5yi3mm6AtbIHThdiuivicuqHChbDd 1yFU6xwxayXtt9pqn4guNjBEyQ/lWpcEr+clxpTM= Message-ID: <6ad08c0c-2c03-4b30-b5a7-dc486aa29c52@dalibo.com> Date: Mon, 22 Sep 2025 15:37:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Indexes on expressions with multiple columns and operators To: Tom Lane Cc: "pgsql-performance@lists.postgresql.org" , Jehan-Guillaume de Rorthais , Christophe Courtois , Laurenz Albe References: <1507576.1758120083@sss.pgh.pa.us> <62133334-b844-4d0b-b248-1a8446757e5f@dalibo.com> <1916727.1758209549@sss.pgh.pa.us> <1972974.1758213639@sss.pgh.pa.us> <76fbd9ef-1fbb-49f0-bc8b-844462b18d1d@dalibo.com> <2432873.1758387110@sss.pgh.pa.us> From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= Content-Language: fr, en-US Autocrypt: addr=frederic.yhuel@dalibo.com; keydata= xjMEXn3bgxYJKwYBBAHaRw8BAQdA6tX5FT/n5ztMWIoBdl6k5avvu65fv6ryfVzIx/aH3V3N JEYuIFlodWVsIDxmcmVkZXJpYy55aHVlbEBkYWxpYm8uY29tPsKWBBMWCAA+FiEEi7OTyf6H ePS+C6n11XGWhN8zGNUFAmZDVJ8CGwMFCQtfi90FCwkIBwIGFQoJCAsCBBYCAwECHgECF4AA CgkQ1XGWhN8zGNV65gEA6o+UrebFjn2CIAOYwP3CiiJugiM5TMH9yJyehQua5ZoA/2ChxiVn 8OUaAw/ErxJmQi1mSN0tNZBL/KhkUPBDUDQNzjgEXn3bgxIKKwYBBAGXVQEFAQEHQCuh5cLQ AtEBXHa2Fmtp0kduBu7msM7qO/gaEcdjFUdiAwEIB8J+BBgWCAAmAhsMFiEEi7OTyf6HePS+ C6n11XGWhN8zGNUFAmZDVJ8FCQtfi90ACgkQ1XGWhN8zGNWOOAEArSqePBqfd4Kx4ulACaWO 6fM+XSDfUlBAQXx9rU6DR4MBALwozl9g91tRysim6lKxggvBfp/PvbpTZNrxYLWB2fYP In-Reply-To: <2432873.1758387110@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/20/25 18:51, Tom Lane wrote: > I concluded that maybe I was overthinking this part. We only really > need to check the rowcount estimate, since the indexscan cost estimate > is already okay. And stats_ext.sql seems to have gotten away with > assuming that rowcount estimates are reliably reproducible on > not-too-large tables. This bug affects use of extended statistics > too, so a test using those is good enough to show it's fixed; we don't > really need to use an expression index for the purpose. So, I added a > test case in stats_ext.sql and pushed it. OK, great! Thanks for the detailed explanation. Regarding extended statistics, it's unfortunate that they cannot be used in this case. Multivariate MCV statistics work as long as the number of rows in the table is reasonably small (100K) and the STATISTICS value for a column is high enough (it doesn't matter which column, because only the sample size matters). I wonder if this is an argument in favour of decoupling the sample size and the precision of the statistics. Here, we basically want the sample size to be as big as the table in order to include the few (NULL, WARNING) values. Or maybe we need a different kind of extended statistics?