pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow for plugin control over path generation strategies.
Date: Wed, 28 Jan 2026 17:08:03 +0000
Message-ID: <E1vl91O-003D4k-3A@gemulon.postgresql.org> (raw)

Allow for plugin control over path generation strategies.

Each RelOptInfo now has a pgs_mask member which is a mask of acceptable
strategies. For most rels, this is populated from PlannerGlobal's
default_pgs_mask, which is computed from the values of the enable_*
GUCs at the start of planning.

For baserels, get_relation_info_hook can be used to adjust pgs_mask for
each new RelOptInfo, at least for rels of type RTE_RELATION. Adjusting
pgs_mask is less useful for other types of rels, but if it proves to
be necessary, we can revisit the way this hook works or add a new one.

For joinrels, two new hooks are added. joinrel_setup_hook is called each
time a joinrel is created, and one thing that can be done from that hook
is to manipulate pgs_mask for the new joinrel. join_path_setup_hook is
called each time we're about to add paths to a joinrel by considering
some particular combination of an outer rel, an inner rel, and a join
type. It can modify the pgs_mask propagated into JoinPathExtraData to
restrict strategy choice for that particular combination of rels.

To make joinrel_setup_hook work as intended, the existing calls to
build_joinrel_partition_info are moved later in the calling functions;
this is because that function checks whether the rel's pgs_mask includes
PGS_CONSIDER_PARTITIONWISE, so we want it to only be called after
plugins have had a chance to alter pgs_mask.

Upper rels currently inherit pgs_mask from the input relation. It's
unclear that this is the most useful behavior, but at the moment there
are no hooks to allow the mask to be set in any other way.

Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Discussion: http://postgr.es/m/CA+TgmoZ-Jh1T6QyWoCODMVQdhTUPYkaZjWztzP1En4=ZHoKPzw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4020b370f214315b8c10430301898ac21658143f

Modified Files
--------------
src/backend/optimizer/path/allpaths.c   |   2 +-
src/backend/optimizer/path/costsize.c   | 222 +++++++++++++++++++++++++-------
src/backend/optimizer/path/indxpath.c   |   4 +-
src/backend/optimizer/path/joinpath.c   |  89 +++++++++----
src/backend/optimizer/path/tidpath.c    |   7 +-
src/backend/optimizer/plan/createplan.c |   4 +-
src/backend/optimizer/plan/planner.c    |  54 ++++++++
src/backend/optimizer/util/pathnode.c   |  19 ++-
src/backend/optimizer/util/plancat.c    |   3 +
src/backend/optimizer/util/relnode.c    |  44 +++++--
src/include/nodes/pathnodes.h           |  82 +++++++++++-
src/include/optimizer/cost.h            |   4 +-
src/include/optimizer/pathnode.h        |  12 +-
src/include/optimizer/paths.h           |   9 +-
14 files changed, 457 insertions(+), 98 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1vl91O-003D4k-3A@gemulon.postgresql.org>
Permalink:  ../E1vl91O-003D4k-3A@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vl91O-003D4k-3A@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: rhaas@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow for plugin control over path generation strategies.
  In-Reply-To: <E1vl91O-003D4k-3A@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