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 1uzcFE-005WJS-5T for pgsql-performance@arkaria.postgresql.org; Fri, 19 Sep 2025 14:37:52 +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 1uzcFC-007mMC-Rv for pgsql-performance@arkaria.postgresql.org; Fri, 19 Sep 2025 14:37:50 +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 1uzcFC-007mM4-I0 for pgsql-performance@lists.postgresql.org; Fri, 19 Sep 2025 14:37:50 +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 1uzcF9-001He8-15 for pgsql-performance@lists.postgresql.org; Fri, 19 Sep 2025 14:37:49 +0000 Received: from karst (82-65-23-130.subs.proxad.net [82.65.23.130]) by mail.dalibo.com (Postfix) with ESMTPSA id 34AB326F44; Fri, 19 Sep 2025 16:37:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1758292666; bh=T5cugSi0TVmvKcQLlS6eQNaKKC6LDJigtYbEUnugeiM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EWD7mapqG+kICg3sPupPsetHvj0uokOSv6omz6Aoe5FQtjEoGftJsiZUpI3FtO12m VRXUFQYbQ2u5JUenIH8+vCzFmlZgV/OklHYhZgX4GCIOyLKNsbBGhuS/NtKUsslcng 2VZHXdj84OvKgiSlJUAgaydb/2YhOOS7cg9GqW1g= Date: Fri, 19 Sep 2025 16:37:45 +0200 From: Jehan-Guillaume de Rorthais To: Tom Lane Cc: =?UTF-8?B?RnLDqWTDqXJpYw==?= Yhuel , "pgsql-performance@lists.postgresql.org" , Christophe Courtois , Laurenz Albe Subject: Re: Indexes on expressions with multiple columns and operators Message-ID: <20250919163745.1dfc1044@karst> In-Reply-To: <1975239.1758214751@sss.pgh.pa.us> References: <1507576.1758120083@sss.pgh.pa.us> <20250918172628.44301672@karst> <1975239.1758214751@sss.pgh.pa.us> Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 18 Sep 2025 12:59:11 -0400 Tom Lane wrote: > Jehan-Guillaume de Rorthais writes: > > On a fresh instance from HEAD with its default configuration, it shows: > > > Index Scan using foo_s_idx on foo (cost=0.29..8.39 rows=33333 width=13) > > Index Cond: (s(crit, ackid) = true) > > > It seems statistics shown in "pg_stats" view for function "s()" are good. > > The query itself even have the same costs than the query using the syntax > > tips you provide before. > > > However, the estimated row number seems wrong in regard with the costs shown > > and statistics. > > Yeah. The problem is that clause_selectivity_ext fails to consider > use of statistics if the clause looks like "bool_valued_function(...)". > If it looks like "bool_valued_function(...) = true", that goes down > a different code path that does the right thing. Oh, OK, I understand. Thanks for your explanations! Regards,