pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Re-allow using statistics for bool-valued functions in WHERE.
Date: Sat, 20 Sep 2025 16:44:58 +0000
Message-ID: <E1v00hm-001fiv-0E@gemulon.postgresql.org> (raw)

Re-allow using statistics for bool-valued functions in WHERE.

Commit a391ff3c3, which added the ability for a function's support
function to provide a custom selectivity estimate for "WHERE f(...)",
unintentionally removed the possibility of applying expression
statistics after finding there's no applicable support function.
That happened because we no longer fell through to boolvarsel()
as before.  Refactor to do so again, putting the 0.3333333 default
back into boolvarsel() where it had been (cf. commit 39df0f150).

I surely wouldn't have made this error if 39df0f150 had included
a test case, so add one now.  At the time we did not have the
"extended statistics" infrastructure, but we do now, and it is
also unable to work in this scenario because of this error.
So make use of that for the test case.

This is very clearly a bug fix, but I'm afraid to put it into
released branches because of the likelihood of altering plan
choices, which we avoid doing in minor releases.  So, master only.

Reported-by: Frédéric Yhuel <frederic.yhuel@dalibo.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/a8b99dce-1bfb-4d97-af73-54a32b85c916@dalibo.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1eccb93150707acfcc8f24556a15742a6313c8ac

Modified Files
--------------
src/backend/optimizer/path/clausesel.c  |  4 ++++
src/backend/optimizer/util/plancat.c    | 17 ++++-------------
src/backend/utils/adt/selfuncs.c        | 11 +++++++++++
src/test/regress/expected/stats_ext.out | 20 ++++++++++++++++++++
src/test/regress/sql/stats_ext.sql      | 14 ++++++++++++++
5 files changed, 53 insertions(+), 13 deletions(-)



Message-ID: <E1v00hm-001fiv-0E@gemulon.postgresql.org>
Permalink:  ../E1v00hm-001fiv-0E@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1v00hm-001fiv-0E@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Re-allow using statistics for bool-valued functions in WHERE.
  In-Reply-To: <E1v00hm-001fiv-0E@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox