@@ -102,8 +102,8 @@ create_partial_tempscan_path(PlannerInfo *root, RelOptInfo *rel,
102102 pathnode -> parallel_workers = path -> parallel_workers ;
103103
104104 /* DEBUGGING purposes only */
105- pathnode -> startup_cost = path -> startup_cost /*/ disable_cost*/ ;
106- pathnode -> total_cost = path -> total_cost /*/ disable_cost*/ ;
105+ pathnode -> startup_cost = path -> startup_cost ;
106+ pathnode -> total_cost = path -> total_cost ;
107107
108108 cpath -> custom_paths = list_make1 (path );
109109 cpath -> custom_private = NIL ;
@@ -206,7 +206,8 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
206206 RangeTblEntry * rte )
207207{
208208 int parallel_workers ;
209- Path * path ;
209+ ListCell * lc ;
210+ List * partial_pathlist_new = NIL ;
210211
211212 /*
212213 * Some extension intercept this hook earlier. Allow it to do a work
@@ -234,16 +235,33 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
234235 if (parallel_workers <= 0 )
235236 return ;
236237
238+ /* Enable parallel paths generation for this relation */
239+ Assert (rel -> partial_pathlist == NIL );
237240 rel -> consider_parallel = true;
238241
239- path = create_seqscan_path (root , rel , NULL , parallel_workers );
240- if (path )
242+ /* Add partial sequental scan path. */
243+ add_partial_path (rel , (Path * )
244+ create_seqscan_path (root , rel , NULL , parallel_workers ));
245+
246+ /* Add there more specific paths too */
247+ create_index_paths (root , rel );
248+ create_tidscan_paths (root , rel );
249+
250+ foreach (lc , rel -> partial_pathlist )
241251 {
242- /* Add an unordered partial path based on a parallel sequential scan. */
243- add_partial_path (rel , (Path * )
244- create_partial_tempscan_path (root , rel , path ));
252+ Path * path = lfirst (lc );
253+
254+ partial_pathlist_new =
255+ lappend (partial_pathlist_new ,
256+ (void * ) create_partial_tempscan_path (root , rel , path ));
245257 }
246258
259+ /*
260+ * Dangerous zone. But we assume it is strictly local. What about extension
261+ * which could call ours and add some paths after us?
262+ */
263+ rel -> partial_pathlist = partial_pathlist_new ;
264+
247265 Assert (IsA (linitial (rel -> partial_pathlist ), CustomPath ));
248266}
249267
0 commit comments