diff options
Diffstat (limited to 'src/include/executor/execPartition.h')
-rw-r--r-- | src/include/executor/execPartition.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/include/executor/execPartition.h b/src/include/executor/execPartition.h index 63c883093ea..b2daf24c41d 100644 --- a/src/include/executor/execPartition.h +++ b/src/include/executor/execPartition.h @@ -17,6 +17,7 @@ #include "nodes/execnodes.h" #include "nodes/parsenodes.h" #include "nodes/plannodes.h" +#include "partitioning/partprune.h" /*----------------------- * PartitionDispatch - information about one partitioned table in a partition @@ -108,6 +109,77 @@ typedef struct PartitionTupleRouting TupleTableSlot *root_tuple_slot; } PartitionTupleRouting; +/*----------------------- + * PartitionPruningData - Encapsulates all information required to support + * elimination of partitions in node types which support arbitrary Lists of + * subplans. Information stored here allows the planner's partition pruning + * functions to be called and the return value of partition indexes translated + * into the subpath indexes of node types such as Append, thus allowing us to + * bypass certain subnodes when we have proofs that indicate that no tuple + * matching the 'pruning_steps' will be found within. + * + * subnode_map An array containing the subnode index which + * matches this partition index, or -1 if the + * subnode has been pruned already. + * 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. + * context Contains the context details required to call + * the partition pruning code. + * pruning_steps Contains a list of PartitionPruneStep 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. + *----------------------- + */ +typedef struct PartitionPruningData +{ + int *subnode_map; + int *subpart_map; + Bitmapset *present_parts; + PartitionPruneContext context; + List *pruning_steps; + Bitmapset *extparams; + Bitmapset *allparams; +} 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. + * 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 + * possibly produce. + * + * partprunedata Array of PartitionPruningData for the node's target + * partitioned relation. First element contains the + * details for the target partitioned table. + * num_partprunedata Number of items in 'partprunedata' array. + * 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. + *----------------------- + */ +typedef struct PartitionPruneState +{ + PartitionPruningData *partprunedata; + int num_partprunedata; + MemoryContext prune_context; + Bitmapset *extparams; + Bitmapset *execparams; + Bitmapset *allparams; +} PartitionPruneState; + extern PartitionTupleRouting *ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, Relation rel); extern int ExecFindPartition(ResultRelInfo *resultRelInfo, @@ -133,5 +205,10 @@ extern HeapTuple ConvertPartitionTupleSlot(TupleConversionMap *map, TupleTableSlot **p_my_slot); extern void ExecCleanupTupleRouting(ModifyTableState *mtstate, PartitionTupleRouting *proute); +extern PartitionPruneState *ExecSetupPartitionPruneState(PlanState *planstate, + List *partitionpruneinfo); +extern Bitmapset *ExecFindMatchingSubPlans(PartitionPruneState *prunestate); +extern Bitmapset *ExecFindInitialMatchingSubPlans(PartitionPruneState *prunestate, + int nsubnodes); #endif /* EXECPARTITION_H */ |