pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Guo <rguo@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Expand virtual generated columns before sublink pull-up
Date: Tue, 22 Jul 2025 02:23:08 +0000
Message-ID: <E1ue2eq-0007MI-02@gemulon.postgresql.org> (raw)

Expand virtual generated columns before sublink pull-up

Currently, we expand virtual generated columns after we have pulled up
any SubLinks within the query's quals.  This ensures that the virtual
generated column references within SubLinks that should be transformed
into joins are correctly expanded.  This approach works well and has
posed no issues.

In an upcoming patch, we plan to centralize the collection of catalog
information needed early in the planner.  This will help avoid
repeated table_open/table_close calls for relations in the rangetable.
Since this information is required during sublink pull-up, we are
moving the expansion of virtual generated columns to occur beforehand.

To achieve this, if any EXISTS SubLinks can be pulled up, their
rangetables are processed just before pulling them up.

Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAMbWs4-bFJ1At4btk5wqbezdu8PLtQ3zv-aiaY3ry9Ymm=jgFQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e0d05295268e3811e6743403cb779f21d1662426

Modified Files
--------------
src/backend/optimizer/plan/planner.c            | 17 ++++++++--------
src/backend/optimizer/plan/subselect.c          | 27 +++++++++++++++++++++++++
src/backend/optimizer/prep/prepjointree.c       | 20 ++++++++----------
src/include/optimizer/prep.h                    |  2 +-
src/test/regress/expected/generated_virtual.out | 22 ++++++++++++++++++++
src/test/regress/sql/generated_virtual.sql      |  9 +++++++++
6 files changed, 76 insertions(+), 21 deletions(-)



Message-ID: <E1ue2eq-0007MI-02@gemulon.postgresql.org>
Permalink:  ../E1ue2eq-0007MI-02@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ue2eq-0007MI-02@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: rguo@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Expand virtual generated columns before sublink pull-up
  In-Reply-To: <E1ue2eq-0007MI-02@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