MCPcopy Create free account
hub / github.com/apache/cloudberry / create_gather_merge_path

Function create_gather_merge_path

src/backend/optimizer/util/pathnode.c:2911–2964  ·  view source on GitHub ↗

* create_gather_merge_path * * Creates a path corresponding to a gather merge scan, returning * the pathnode. */

Source from the content-addressed store, hash-verified

2909 * the pathnode.
2910 */
2911GatherMergePath *
2912create_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

Callers 4

create_ordered_pathsFunction · 0.85
gather_grouping_pathsFunction · 0.85
generate_gather_pathsFunction · 0.85

Calls 4

pathkeys_contained_inFunction · 0.85
cost_sortFunction · 0.85
cost_gather_mergeFunction · 0.85

Tested by

no test coverage detected