From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Restructure creation of run-time pruning steps. |
Date: | 2019-05-17 23:44:43 |
Message-ID: | E1hRmWp-0003zC-E8@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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
------
REL_11_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/592d5d75be9720e575e76ba35c3ff04659ec0603
Modified Files
--------------
src/backend/executor/execPartition.c | 206 ++++---
src/backend/nodes/copyfuncs.c | 2 +
src/backend/nodes/outfuncs.c | 2 +
src/backend/nodes/readfuncs.c | 2 +
src/backend/partitioning/partprune.c | 781 ++++++++++++++------------
src/include/executor/execPartition.h | 26 +-
src/include/nodes/plannodes.h | 11 +-
src/include/partitioning/partprune.h | 6 -
src/test/regress/expected/partition_prune.out | 38 ++
src/test/regress/sql/partition_prune.sql | 19 +
10 files changed, 627 insertions(+), 466 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2019-05-18 02:10:46 | pgsql: tableam: Avoid relying on relation size to determine validity of |
Previous Message | Bruce Momjian | 2019-05-17 15:31:52 | pgsql: docs: split out sort-skip partition item in PG 12 release notes |