* create_gather_merge_path * * Creates a path corresponding to a gather merge scan, returning * the pathnode. */
| 2909 | * the pathnode. |
| 2910 | */ |
| 2911 | GatherMergePath * |
| 2912 | create_gather_merge_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, |
| 2913 | PathTarget *target, List *pathkeys, |
| 2914 | Relids required_outer, double *rows) |
| 2915 | { |
| 2916 | Assert(false); |
| 2917 | GatherMergePath *pathnode = makeNode(GatherMergePath); |
| 2918 | Cost input_startup_cost = 0; |
| 2919 | Cost input_total_cost = 0; |
| 2920 | |
| 2921 | Assert(subpath->parallel_safe); |
| 2922 | Assert(pathkeys); |
| 2923 | |
| 2924 | pathnode->path.pathtype = T_GatherMerge; |
| 2925 | pathnode->path.parent = rel; |
| 2926 | pathnode->path.param_info = get_baserel_parampathinfo(root, rel, |
| 2927 | required_outer); |
| 2928 | pathnode->path.parallel_aware = false; |
| 2929 | |
| 2930 | pathnode->subpath = subpath; |
| 2931 | pathnode->num_workers = subpath->parallel_workers; |
| 2932 | pathnode->path.pathkeys = pathkeys; |
| 2933 | pathnode->path.pathtarget = target ? target : rel->reltarget; |
| 2934 | pathnode->path.rows += subpath->rows; |
| 2935 | |
| 2936 | if (pathkeys_contained_in(pathkeys, subpath->pathkeys)) |
| 2937 | { |
| 2938 | /* Subpath is adequately ordered, we won't need to sort it */ |
| 2939 | input_startup_cost += subpath->startup_cost; |
| 2940 | input_total_cost += subpath->total_cost; |
| 2941 | } |
| 2942 | else |
| 2943 | { |
| 2944 | /* We'll need to insert a Sort node, so include cost for that */ |
| 2945 | Path sort_path; /* dummy for result of cost_sort */ |
| 2946 | |
| 2947 | cost_sort(&sort_path, |
| 2948 | root, |
| 2949 | pathkeys, |
| 2950 | subpath->total_cost, |
| 2951 | subpath->rows, |
| 2952 | subpath->pathtarget->width, |
| 2953 | 0.0, |
| 2954 | work_mem, |
| 2955 | -1); |
| 2956 | input_startup_cost += sort_path.startup_cost; |
| 2957 | input_total_cost += sort_path.total_cost; |
| 2958 | } |
| 2959 | |
| 2960 | cost_gather_merge(pathnode, root, rel, pathnode->path.param_info, |
| 2961 | input_startup_cost, input_total_cost, rows); |
| 2962 | |
| 2963 | return pathnode; |
| 2964 | } |
| 2965 | |
| 2966 | /* |
| 2967 | * translate_sub_tlist - get subquery column numbers represented by tlist |
no test coverage detected