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 1uzGci-001XnY-Q5 for pgsql-performance@arkaria.postgresql.org; Thu, 18 Sep 2025 15:32:40 +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 1uzGch-00HUio-EP for pgsql-performance@arkaria.postgresql.org; Thu, 18 Sep 2025 15:32:39 +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 1uzGch-00HUif-4r for pgsql-performance@lists.postgresql.org; Thu, 18 Sep 2025 15:32:39 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uzGcd-001WuC-0S for pgsql-performance@lists.postgresql.org; Thu, 18 Sep 2025 15:32:38 +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 58IFWTqT1916728; Thu, 18 Sep 2025 11:32:29 -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: <62133334-b844-4d0b-b248-1a8446757e5f@dalibo.com> References: <1507576.1758120083@sss.pgh.pa.us> <62133334-b844-4d0b-b248-1a8446757e5f@dalibo.com> Comments: In-reply-to =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= message dated "Wed, 17 Sep 2025 16:57:26 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1916726.1758209549.1@sss.pgh.pa.us> Date: Thu, 18 Sep 2025 11:32:29 -0400 Message-ID: <1916727.1758209549@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/17/25 16:41, Tom Lane wrote: >> =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= writes: >>> 2) the number of estimated rows is completely off in the second EXPLAIN, >>> whereas the planner could easily use the statistics of foo_f_idx. >> Hmm, not sure about that. Again, boolean-valued indexes aren't >> something we've worked on too hard, but I don't see why that >> would affect this case. > OK, thanks anyway, I think the ju-jitsu mentioned above will do, even > though the application code will have to be patched. Sigh ... so the answer is this used to work (since commit 39df0f150) and then I carelessly broke it in commit a391ff3c3. If you try this test case in versions 9.5..11 you get a spot-on rowcount estimate. Serves me right for not having a test case I guess, but I'm astonished that nobody complained sooner. regards, tom lane