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

Function compare_path_costs

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

* compare_path_costs * Return -1, 0, or +1 according as path1 is cheaper, the same cost, * or more expensive than path2 for the specified criterion. */

Source from the content-addressed store, hash-verified

93 * or more expensive than path2 for the specified criterion.
94 */
95int
96compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
97{
98 if (criterion == STARTUP_COST)
99 {
100 if (path1->startup_cost < path2->startup_cost)
101 return -1;
102 if (path1->startup_cost > path2->startup_cost)
103 return +1;
104
105 /*
106 * If paths have the same startup cost (not at all unlikely), order
107 * them by total cost.
108 */
109 if (path1->total_cost < path2->total_cost)
110 return -1;
111 if (path1->total_cost > path2->total_cost)
112 return +1;
113 }
114 else
115 {
116 if (path1->total_cost < path2->total_cost)
117 return -1;
118 if (path1->total_cost > path2->total_cost)
119 return +1;
120
121 /*
122 * If paths have the same total cost, order them by startup cost.
123 */
124 if (path1->startup_cost < path2->startup_cost)
125 return -1;
126 if (path1->startup_cost > path2->startup_cost)
127 return +1;
128 }
129 return 0;
130}
131
132/*
133 * compare_path_fractional_costs

Callers 8

generate_mergejoin_pathsFunction · 0.85
set_cheapestFunction · 0.85
get_cheaper_relFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected