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 1v00ob-009XKh-9o for pgsql-performance@arkaria.postgresql.org; Sat, 20 Sep 2025 16:52:01 +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 1v00oY-00DXGn-I0 for pgsql-performance@arkaria.postgresql.org; Sat, 20 Sep 2025 16:51:58 +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 1v00oY-00DXGK-7X for pgsql-performance@lists.postgresql.org; Sat, 20 Sep 2025 16:51:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v00oW-001TAn-0e for pgsql-performance@lists.postgresql.org; Sat, 20 Sep 2025 16:51:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 58KGpoFW2432874; Sat, 20 Sep 2025 12:51:51 -0400 From: Tom Lane To: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= cc: "pgsql-performance@lists.postgresql.org" , Jehan-Guillaume de Rorthais , Christophe Courtois , Laurenz Albe Subject: Re: Indexes on expressions with multiple columns and operators In-reply-to: <76fbd9ef-1fbb-49f0-bc8b-844462b18d1d@dalibo.com> 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> Comments: In-reply-to =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= message dated "Fri, 19 Sep 2025 09:50:26 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2432872.1758387110.1@sss.pgh.pa.us> Date: Sat, 20 Sep 2025 12:51:50 -0400 Message-ID: <2432873.1758387110@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= writes: > On 9/18/25 18:40, Tom Lane wrote: >> The attached fixes things so it works like it did pre-a391ff3c3. > Indeed, it works well! Thanks for testing! >> I spent some time trying to devise a test case, and was reminded >> of why I didn't have one before: it's hard to make a case that >> will be robust enough to not show diffs in the buildfarm. >> I'll keep thinking about that though. > It looks like an interesting homework for an aspiring hacker :-) > So I'll try to devise one, too. 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. I wish we could back-patch this, since it's so obviously a bug fix. But we avoid changing plans in released branches, and at this point it's even too late for v18. Thank you again for the report. regards, tom lane