forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd47cbf4
committed
Perform runtime initial pruning outside ExecInitNode()
This commit builds on the prior change that moved PartitionPruneInfosout of individual plan nodes into a list in PlannedStmt, making itpossible to initialize PartitionPruneStates without traversing theplan tree and perform runtime initial pruning before ExecInitNode()initializes the plan trees. These tasks are now handled in a newroutine, ExecDoInitialPruning(), which is called by InitPlan()before calling ExecInitNode() on various plan trees.ExecDoInitialPruning() performs the initial pruning and saves theresult -- a Bitmapset of indexes for surviving child subnodes -- ines_part_prune_results, a list in EState.PartitionPruneStates created for initial pruning are stored ines_part_prune_states, another list in EState, for later use duringexec pruning. Both lists are parallel to es_part_prune_infos, whichholds the PartitionPruneInfos from PlannedStmt, enabling sharedindexing.PartitionPruneStates initialized in ExecDoInitialPruning() nowinclude only the PartitionPruneContexts for initial pruning steps.Exec pruning contexts are initialized later inExecInitPartitionExecPruning() when the parent plan node isinitialized, as the exec pruning step expressions depend on the parentnode's PlanState.The existing function PartitionPruneFixSubPlanMap() has beenrepurposed for this initialization to avoid duplicating a similarloop structure for finding PartitionedRelPruningData to initializeexec pruning contexts for. It has been renamed toInitExecPruningContexts() to reflect its new primary responsibility.The original logic to "fix subplan maps" remains intact but is nowencapsulated within the renamed function.This commit removes two obsolete Asserts in partkey_datum_from_expr().The ExprContext used for pruning expression evaluation is nowindependent of the parent PlanState, making these Asserts unnecessary.By centralizing pruning logic and decoupling it from the planinitialization step (ExecInitNode()), this change sets the stage forfuture patches that will use the result of initial pruning tosave the overhead of redundant processing for pruned partitions.Reviewed-by: Robert Haas <robertmhaas@gmail.com>Reviewed-by: Tomas Vondra <tomas@vondra.me>Discussion:https://postgr.es/m/CA+HiwqFGkMSge6TgC9KQzde0ohpAycLQuV7ooitEEpbKB0O_mg@mail.gmail.com1 parentf41d846 commitd47cbf4
File tree
8 files changed
+271
-114
lines changed- src
- backend
- executor
- partitioning
- include
- executor
- nodes
8 files changed
+271
-114
lines changedLines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
| 49 | + | |
49 | 50 |
| |
50 | 51 |
| |
51 | 52 |
| |
| |||
855 | 856 |
| |
856 | 857 |
| |
857 | 858 |
| |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
858 | 870 |
| |
859 | 871 |
| |
860 | 872 |
| |
|
Lines changed: 223 additions & 91 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
144 | 144 |
| |
145 | 145 |
| |
146 | 146 |
| |
147 |
| - | |
148 |
| - | |
149 |
| - | |
150 |
| - | |
151 |
| - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
152 | 152 |
| |
153 | 153 |
| |
154 | 154 |
| |
|
Lines changed: 5 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
92 | 92 |
| |
93 | 93 |
| |
94 | 94 |
| |
95 |
| - | |
96 |
| - | |
97 |
| - | |
98 |
| - | |
99 |
| - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
|
Lines changed: 1 addition & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3783 | 3783 |
| |
3784 | 3784 |
| |
3785 | 3785 |
| |
3786 |
| - | |
3787 |
| - | |
3788 |
| - | |
3789 | 3786 |
| |
3790 |
| - | |
3791 |
| - | |
3792 |
| - | |
| 3787 | + | |
3793 | 3788 |
| |
3794 | 3789 |
| |
3795 | 3790 |
| |
|
Lines changed: 13 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 |
| |
46 | 49 |
| |
47 | 50 |
| |
| |||
58 | 61 |
| |
59 | 62 |
| |
60 | 63 |
| |
| 64 | + | |
61 | 65 |
| |
62 | 66 |
| |
63 | 67 |
| |
| |||
90 | 94 |
| |
91 | 95 |
| |
92 | 96 |
| |
| 97 | + | |
| 98 | + | |
93 | 99 |
| |
94 | 100 |
| |
95 | 101 |
| |
| |||
112 | 118 |
| |
113 | 119 |
| |
114 | 120 |
| |
| 121 | + | |
115 | 122 |
| |
116 | 123 |
| |
117 | 124 |
| |
| |||
121 | 128 |
| |
122 | 129 |
| |
123 | 130 |
| |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 |
| - | |
128 |
| - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
129 | 137 |
| |
130 | 138 |
| |
131 | 139 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
656 | 656 |
| |
657 | 657 |
| |
658 | 658 |
| |
| 659 | + | |
| 660 | + | |
659 | 661 |
| |
660 | 662 |
| |
661 | 663 |
| |
|
Lines changed: 10 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
281 | 281 |
| |
282 | 282 |
| |
283 | 283 |
| |
284 |
| - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
285 | 289 |
| |
286 | 290 |
| |
287 | 291 |
| |
| |||
316 | 320 |
| |
317 | 321 |
| |
318 | 322 |
| |
319 |
| - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
320 | 328 |
| |
321 | 329 |
| |
322 | 330 |
| |
|
0 commit comments
Comments
(0)