- /* Generate gather paths for base rels */
- if (rel->reloptkind == RELOPT_BASEREL)
- generate_gather_paths(root, rel);
+ /* Regenerate paths with the current enforcement */
+ set_plain_rel_pathlist(root, rel, rte);
+
+ /* Additional work to enforce parallel query execution */
+ if (phint && phint->nworkers > 0)
+ {
+ /*
+ * For Parallel Append to be planned properly, we shouldn't set
+ * the costs of non-partial paths to disable-value. Lower the
+ * priority of non-parallel paths by setting partial path costs
+ * to 0 instead.
+ */
+ foreach (l, rel->partial_pathlist)
+ {
+ Path *path = (Path *) lfirst(l);
+
+ path->startup_cost = 0;
+ path->total_cost = 0;
+ }
+
+ /* enforce number of workers if requested */
+ if (phint->force_parallel)
+ {
+ foreach (l, rel->partial_pathlist)
+ {
+ Path *ppath = (Path *) lfirst(l);
+
+ if (ppath->parallel_safe)
+ ppath->parallel_workers = phint->nworkers;
+ }
+ }
+
+ /* Generate gather paths */
+ if (rel->reloptkind == RELOPT_BASEREL)
+ generate_gather_paths(root, rel, false);
+ }