From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix planner to consider matches to boolean columns in extension
Date: Fri, 02 Sep 2022 21:02:01 +0000
Message-ID: <E1oUDnd-0018RN-Au@gemulon.postgresql.org> (raw)
Fix planner to consider matches to boolean columns in extension indexes.
The planner has to special-case indexes on boolean columns, because
what we need for an indexscan on such a column is a qual of the shape
of "boolvar = pseudoconstant". For plain bool constants, previous
simplification will have reduced this to "boolvar" or "NOT boolvar",
and we have to reverse that if we want to make an indexqual. There is
existing code to do so, but it only fires when the index's opfamily
is BOOL_BTREE_FAM_OID or BOOL_HASH_FAM_OID. Thus extension AMs, or
extension opclasses such as contrib/btree_gin, are out in the cold.
The reason for hard-wiring the set of relevant opfamilies was mostly
to avoid a catalog lookup in a hot code path. We can improve matters
while not taking much of a performance hit by relying on the
hard-wired set when the opfamily OID is visibly built-in, and only
checking the catalogs when dealing with an extension opfamily.
While here, rename IsBooleanOpfamily to IsBuiltinBooleanOpfamily
to remind future users of that macro of its limitations. At some
point we might want to make indxpath.c's improved version of the
test globally accessible, but it's not presently needed elsewhere.
Zongliang Quan and Tom Lane
Discussion: https://postgr.es/m/f293b91d-1d46-d386-b6bb-4b06ff5c667b@yeah.net
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/ff720a597c0a53a8fcdf2cf4e45248dc5c37f9ab
Modified Files
--------------
contrib/btree_gin/expected/bool.out | 10 ++++++----
contrib/btree_gist/expected/bool.out | 4 ++--
src/backend/optimizer/path/indxpath.c | 18 ++++++++++++++++++
src/backend/optimizer/path/pathkeys.c | 9 +++++++--
src/backend/partitioning/partprune.c | 6 +++++-
src/include/catalog/pg_opfamily.h | 3 ++-
6 files changed, 40 insertions(+), 10 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Fix planner to consider matches to boolean columns in extension
In-Reply-To: <E1oUDnd-0018RN-Au@gemulon.postgresql.org>
References: <E1oUDnd-0018RN-Au@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