* generate_gather_paths * Generate parallel access paths for a relation by pushing a Gather or * Gather Merge on top of a partial path. * * This must not be called until after we're done creating all partial paths * for the specified relation. (Otherwise, add_partial_path might delete a * path that some GatherPath or GatherMergePath has a reference to.) * * If we're generating paths for
| 3310 | * we must do something.) |
| 3311 | */ |
| 3312 | void |
| 3313 | generate_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_rows) |
| 3314 | { |
| 3315 | Assert(false); |
| 3316 | Path *cheapest_partial_path; |
| 3317 | Path *simple_gather_path; |
| 3318 | ListCell *lc; |
| 3319 | double rows; |
| 3320 | double *rowsp = NULL; |
| 3321 | |
| 3322 | /* If there are no partial paths, there's nothing to do here. */ |
| 3323 | if (rel->partial_pathlist == NIL) |
| 3324 | return; |
| 3325 | |
| 3326 | /* Should we override the rel's rowcount estimate? */ |
| 3327 | if (override_rows) |
| 3328 | rowsp = &rows; |
| 3329 | |
| 3330 | /* |
| 3331 | * The output of Gather is always unsorted, so there's only one partial |
| 3332 | * path of interest: the cheapest one. That will be the one at the front |
| 3333 | * of partial_pathlist because of the way add_partial_path works. |
| 3334 | */ |
| 3335 | cheapest_partial_path = linitial(rel->partial_pathlist); |
| 3336 | |
| 3337 | if (!cheapest_partial_path->parallel_safe) |
| 3338 | return; |
| 3339 | |
| 3340 | rows = |
| 3341 | cheapest_partial_path->rows * cheapest_partial_path->parallel_workers; |
| 3342 | simple_gather_path = (Path *) |
| 3343 | create_gather_path(root, rel, cheapest_partial_path, rel->reltarget, |
| 3344 | NULL, rowsp); |
| 3345 | add_path(rel, simple_gather_path, root); |
| 3346 | |
| 3347 | /* |
| 3348 | * For each useful ordering, we can consider an order-preserving Gather |
| 3349 | * Merge. |
| 3350 | */ |
| 3351 | foreach(lc, rel->partial_pathlist) |
| 3352 | { |
| 3353 | Path *subpath = (Path *) lfirst(lc); |
| 3354 | GatherMergePath *path; |
| 3355 | |
| 3356 | if (subpath->pathkeys == NIL) |
| 3357 | continue; |
| 3358 | |
| 3359 | rows = subpath->rows * subpath->parallel_workers; |
| 3360 | path = create_gather_merge_path(root, rel, subpath, rel->reltarget, |
| 3361 | subpath->pathkeys, NULL, rowsp); |
| 3362 | add_path(rel, &path->path, root); |
| 3363 | } |
| 3364 | } |
| 3365 | |
| 3366 | /* |
| 3367 | * get_useful_pathkeys_for_relation |
no test coverage detected