pgsql: Restructure creation of run-time pruning steps.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Restructure creation of run-time pruning steps.
Дата
Msg-id E1hRmWp-0003zC-E8@gemulon.postgresql.org
обсуждение исходный текст
Список 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(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: pgsql: docs: split out sort-skip partition item in PG 12 release notes
Следующее
От: Andres Freund
Дата:
Сообщение: pgsql: tableam: Don't assume that every AM uses md.c style storage.