Commit 5076f88b authored by Tom Lane's avatar Tom Lane

Remove incidental dependencies on partitioned_rels lists.

It turns out that the calculation of [Merge]AppendPath.partitioned_rels
in allpaths.c is faulty and sometimes omits relevant non-leaf partitions,
allowing an assertion added by commit a929e17e to trigger.  Rather
than fix that, it seems better to get rid of those fields altogether.
We don't really need the info until create_plan time, and calculating
it once for the selected plan should be cheaper than calculating it
for each append path we consider.

This patch undoes a couple of very minor uses of the partitioned_rels
values.

createplan.c was testing for nil-ness to optimize away the preparatory
work for make_partition_pruneinfo().  That is worth doing if the check
is nigh free, but it's not worth going to any great lengths to avoid.

create_append_path() was testing for nil-ness as part of deciding how
to set up ParamPathInfo for an AppendPath.  I replaced that with a
check for the appendrel's parent rel being partitioned.  That's not
quite the same thing but should cover most cases.  If we note any
interesting loss of optimizations, we can dumb this down to just
always use the more expensive method when the parent is a baserel.

Discussion: https://postgr.es/m/87sg8tqhsl.fsf@aurora.ydns.eu
Discussion: https://postgr.es/m/CAJKUy5gCXDSmFs2c=R+VGgn7FiYcLCsEFEuDNNLGfoha=pBE_g@mail.gmail.com
parent fb2d645d
...@@ -1227,8 +1227,7 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags) ...@@ -1227,8 +1227,7 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags)
* pruning during execution. Gather information needed by the executor to * pruning during execution. Gather information needed by the executor to
* do partition pruning. * do partition pruning.
*/ */
if (enable_partition_pruning && if (enable_partition_pruning)
best_path->partitioned_rels != NIL)
{ {
List *prunequal; List *prunequal;
...@@ -1393,8 +1392,7 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, ...@@ -1393,8 +1392,7 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path,
* pruning during execution. Gather information needed by the executor to * pruning during execution. Gather information needed by the executor to
* do partition pruning. * do partition pruning.
*/ */
if (enable_partition_pruning && if (enable_partition_pruning)
best_path->partitioned_rels != NIL)
{ {
List *prunequal; List *prunequal;
......
...@@ -1230,15 +1230,14 @@ create_append_path(PlannerInfo *root, ...@@ -1230,15 +1230,14 @@ create_append_path(PlannerInfo *root,
/* /*
* When generating an Append path for a partitioned table, there may be * When generating an Append path for a partitioned table, there may be
* parameters that are useful so we can eliminate certain partitions * parameterized quals that are useful for run-time pruning. Hence,
* during execution. Here we'll go all the way and fully populate the * compute path.param_info the same way as for any other baserel, so that
* parameter info data as we do for normal base relations. However, we * such quals will be available for make_partition_pruneinfo(). (This
* need only bother doing this for RELOPT_BASEREL rels, as * would not work right for a non-baserel, ie a scan on a non-leaf child
* RELOPT_OTHER_MEMBER_REL's Append paths are merged into the base rel's * partition, and it's not necessary anyway in that case. Must skip it if
* Append subpaths. It would do no harm to do this, we just avoid it to * we don't have "root", too.)
* save wasting effort.
*/ */
if (partitioned_rels != NIL && root && rel->reloptkind == RELOPT_BASEREL) if (root && rel->reloptkind == RELOPT_BASEREL && IS_PARTITIONED_REL(rel))
pathnode->path.param_info = get_baserel_parampathinfo(root, pathnode->path.param_info = get_baserel_parampathinfo(root,
rel, rel,
required_outer); required_outer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment