diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-06-10 15:22:25 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-06-10 15:22:32 -0400 |
commit | 73b7f48f78d27b1baf1a6541cbaae0fe6bd6186d (patch) | |
tree | c5e92bd3ae8eed8d8cf3519c10b12982d44bcfa8 /src/include/executor/execPartition.h | |
parent | c83e2029909c5411ca11fd841851016f1f9810e6 (diff) |
Improve run-time partition pruning to handle any stable expression.
The initial coding of the run-time-pruning feature only coped with cases
where the partition key(s) are compared to Params. That is a bit silly;
we can allow it to work with any non-Var-containing stable expression, as
long as we take special care with expressions containing PARAM_EXEC Params.
The code is hardly any longer this way, and it's considerably clearer
(IMO at least). Per gripe from Pavel Stehule.
David Rowley, whacked around a bit by me
Discussion: https://postgr.es/m/CAFj8pRBjrufA3ocDm8o4LPGNye9Y+pm1b9kCwode4X04CULG3g@mail.gmail.com
Diffstat (limited to 'src/include/executor/execPartition.h')
-rw-r--r-- | src/include/executor/execPartition.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/include/executor/execPartition.h b/src/include/executor/execPartition.h index fc6e9574e30..0216d2132c9 100644 --- a/src/include/executor/execPartition.h +++ b/src/include/executor/execPartition.h @@ -127,15 +127,16 @@ typedef struct PartitionTupleRouting * subpart_map An array containing the offset into the * 'partprunedata' array in PartitionPruning, or * -1 if there is no such element in that array. - * present_parts A Bitmapset of the partition index that we have - * subnodes mapped for. + * present_parts A Bitmapset of the partition indexes that we + * have subnodes mapped for. * context Contains the context details required to call * the partition pruning code. - * pruning_steps Contains a list of PartitionPruneStep used to + * pruning_steps List of PartitionPruneSteps used to * perform the actual pruning. - * extparams Contains paramids of external params found - * matching partition keys in 'pruning_steps'. - * allparams As 'extparams' but also including exec params. + * do_initial_prune true if pruning should be performed during + * executor startup. + * do_exec_prune true if pruning should be performed during + * executor run. *----------------------- */ typedef struct PartitionPruningData @@ -145,15 +146,14 @@ typedef struct PartitionPruningData Bitmapset *present_parts; PartitionPruneContext context; List *pruning_steps; - Bitmapset *extparams; - Bitmapset *allparams; + bool do_initial_prune; + bool do_exec_prune; } PartitionPruningData; /*----------------------- * PartitionPruneState - State object required for executor nodes to perform * partition pruning elimination of their subnodes. This encapsulates a - * flattened hierarchy of PartitionPruningData structs and also stores all - * paramids which were found to match the partition keys of each partition. + * flattened hierarchy of PartitionPruningData structs. * This struct can be attached to node types which support arbitrary Lists of * subnodes containing partitions to allow subnodes to be eliminated due to * the clauses being unable to match to any tuple that the subnode could @@ -163,24 +163,24 @@ typedef struct PartitionPruningData * partitioned relation. First element contains the * details for the target partitioned table. * num_partprunedata Number of items in 'partprunedata' array. + * do_initial_prune true if pruning should be performed during executor + * startup (at any hierarchy level). + * do_exec_prune true if pruning should be performed during + * executor run (at any hierarchy level). * prune_context A memory context which can be used to call the query * planner's partition prune functions. - * extparams All PARAM_EXTERN paramids which were found to match a - * partition key in each of the contained - * PartitionPruningData structs. - * execparams As above but for PARAM_EXEC. - * allparams Union of 'extparams' and 'execparams', saved to avoid - * recalculation. + * execparamids Contains paramids of PARAM_EXEC Params found within + * any of the partprunedata structs. *----------------------- */ typedef struct PartitionPruneState { PartitionPruningData *partprunedata; int num_partprunedata; + bool do_initial_prune; + bool do_exec_prune; MemoryContext prune_context; - Bitmapset *extparams; - Bitmapset *execparams; - Bitmapset *allparams; + Bitmapset *execparamids; } PartitionPruneState; extern PartitionTupleRouting *ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, |