From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Suppress Append and MergeAppend plan nodes that have a single ch
Date: Mon, 25 Mar 2019 19:42:41 +0000
Message-ID: <E1h8VUX-0006Jo-Q9@gemulon.postgresql.org> (raw)
Suppress Append and MergeAppend plan nodes that have a single child.
If there's only one child relation, the Append or MergeAppend isn't
doing anything useful, and can be elided. It does have a purpose
during planning though, which is to serve as a buffer between parent
and child Var numbering. Therefore we keep it all the way through
to setrefs.c, and get rid of it only after fixing references in the
plan level(s) above it. This works largely the same as setrefs.c's
ancient hack to get rid of no-op SubqueryScan nodes, and can even
share some code with that.
Note the change to make setrefs.c use apply_tlist_labeling rather than
ad-hoc code. This has the effect of propagating the child's resjunk
and ressortgroupref labels, which formerly weren't propagated when
removing a SubqueryScan. Doing that is demonstrably necessary for
the [Merge]Append cases, and seems harmless for SubqueryScan, if only
because trivial_subqueryscan is afraid to collapse cases where the
resjunk marking differs. (I suspect that restriction could now be
removed, though it's unclear that it'd make any new matches possible,
since the outer query can't have references to a child resjunk column.)
David Rowley, reviewed by Alvaro Herrera and Tomas Vondra
Discussion: https://postgr.es/m/CAKJS1f_7u8ATyJ1JGTMHFoKDvZdeF-iEBhs+sM_SXowOr9cArg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/8edd0e79460b414b1d971895312e549e95e12e4f
Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 19 +-
contrib/postgres_fdw/sql/postgres_fdw.sql | 4 +-
src/backend/executor/execAmi.c | 30 ++
src/backend/optimizer/path/allpaths.c | 36 +-
src/backend/optimizer/plan/createplan.c | 8 +-
src/backend/optimizer/plan/setrefs.c | 264 ++++++++-----
src/backend/optimizer/util/pathnode.c | 42 +-
src/test/regress/expected/inherit.out | 73 ++--
src/test/regress/expected/partition_join.out | 61 ++-
src/test/regress/expected/partition_prune.out | 526 +++++++++++--------------
src/test/regress/expected/rowsecurity.out | 22 +-
src/test/regress/expected/union.out | 9 +-
12 files changed, 598 insertions(+), 496 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: Suppress Append and MergeAppend plan nodes that have a single ch
In-Reply-To: <E1h8VUX-0006Jo-Q9@gemulon.postgresql.org>
References: <E1h8VUX-0006Jo-Q9@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