From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Restructure creation of run-time pruning steps.
Date: Fri, 17 May 2019 23:44:43 +0000
Message-ID: <E1hRmWp-0003zB-E0@gemulon.postgresql.org> (raw)
Restructure creation of run-time pruning steps.
Previously, gen_partprune_steps() always built executor pruning steps
using all suitable clauses, including those containing PARAM_EXEC
Params. This meant that the pruning steps were only completely safe
for executor run-time (scan start) pruning. To prune at executor
startup, we had to ignore the steps involving exec Params. But this
doesn't really work in general, since there may be logic changes
needed as well --- for example, pruning according to the last operator's
btree strategy is the wrong thing if we're not applying that operator.
The rules embodied in gen_partprune_steps() and its minions are
sufficiently complicated that tracking their incremental effects in
other logic seems quite impractical.
Short of a complete redesign, the only safe fix seems to be to run
gen_partprune_steps() twice, once to create executor startup pruning
steps and then again for run-time pruning steps. We can save a few
cycles however by noting during the first scan whether we rejected
any clauses because they involved exec Params --- if not, we don't
need to do the second scan.
In support of this, refactor the internal APIs in partprune.c to make
more use of passing information in the GeneratePruningStepsContext
struct, rather than as separate arguments.
This is, I hope, the last piece of our response to a bug report from
Alan Jackson. Back-patch to v11 where this code came in.
Discussion: https://postgr.es/m/FAD28A83-AC73-489E-A058-2681FA31D648@tvsquared.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/6630ccad7a25cad32e2d1a6833fb971602cb67fe
Modified Files
--------------
src/backend/executor/execPartition.c | 180 +++---
src/backend/nodes/copyfuncs.c | 7 +-
src/backend/nodes/outfuncs.c | 7 +-
src/backend/nodes/readfuncs.c | 7 +-
src/backend/partitioning/partprune.c | 784 ++++++++++++++------------
src/include/executor/execPartition.h | 26 +-
src/include/nodes/plannodes.h | 24 +-
src/include/partitioning/partprune.h | 6 -
src/test/regress/expected/partition_prune.out | 39 ++
src/test/regress/sql/partition_prune.sql | 18 +
10 files changed, 614 insertions(+), 484 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: Restructure creation of run-time pruning steps.
In-Reply-To: <E1hRmWp-0003zB-E0@gemulon.postgresql.org>
References: <E1hRmWp-0003zB-E0@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