summaryrefslogtreecommitdiff
path: root/src/include/nodes
diff options
context:
space:
mode:
authorTom Lane2019-05-17 23:44:19 +0000
committerTom Lane2019-05-17 23:44:34 +0000
commit6630ccad7a25cad32e2d1a6833fb971602cb67fe (patch)
tree9eeddfb1e56a6d202bc5711d0b84d3474af15bfb /src/include/nodes
parent05685897f07e7ae5684f0247157faad1f782f889 (diff)
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
Diffstat (limited to 'src/include/nodes')
-rw-r--r--src/include/nodes/plannodes.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 1cce7621c2..1241245566 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -1109,21 +1109,23 @@ typedef struct PartitionedRelPruneInfo
{
NodeTag type;
Index rtindex; /* RT index of partition rel for this level */
- List *pruning_steps; /* List of PartitionPruneStep, see below */
Bitmapset *present_parts; /* Indexes of all partitions which subplans or
- * subparts are present for. */
- int nparts; /* Length of subplan_map[] and subpart_map[] */
- int nexprs; /* Length of hasexecparam[] */
+ * subparts are present for */
+ int nparts; /* Length of the following arrays: */
int *subplan_map; /* subplan index by partition index, or -1 */
int *subpart_map; /* subpart index by partition index, or -1 */
Oid *relid_map; /* relation OID by partition index, or 0 */
- bool *hasexecparam; /* true if corresponding pruning_step contains
- * any PARAM_EXEC Params. */
- bool do_initial_prune; /* true if pruning should be performed
- * during executor startup. */
- bool do_exec_prune; /* true if pruning should be performed during
- * executor run. */
- Bitmapset *execparamids; /* All PARAM_EXEC Param IDs in pruning_steps */
+
+ /*
+ * initial_pruning_steps shows how to prune during executor startup (i.e.,
+ * without use of any PARAM_EXEC Params); it is NIL if no startup pruning
+ * is required. exec_pruning_steps shows how to prune with PARAM_EXEC
+ * Params; it is NIL if no per-scan pruning is required.
+ */
+ List *initial_pruning_steps; /* List of PartitionPruneStep */
+ List *exec_pruning_steps; /* List of PartitionPruneStep */
+ Bitmapset *execparamids; /* All PARAM_EXEC Param IDs in
+ * exec_pruning_steps */
} PartitionedRelPruneInfo;
/*