mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
Support parallel aggregation.
Parallel workers can now partially aggregate the data and pass the transition values back to the leader, which can combine the partial results to produce the final answer. David Rowley, based on earlier work by Haribabu Kommi. Reviewed by Álvaro Herrera, Tomas Vondra, Amit Kapila, James Sewell, and me.
This commit is contained in:
@@ -350,16 +350,22 @@ cost_samplescan(Path *path, PlannerInfo *root,
|
||||
*
|
||||
* 'rel' is the relation to be operated upon
|
||||
* 'param_info' is the ParamPathInfo if this is a parameterized path, else NULL
|
||||
* 'rows' may be used to point to a row estimate; if non-NULL, it overrides
|
||||
* both 'rel' and 'param_info'. This is useful when the path doesn't exactly
|
||||
* correspond to any particular RelOptInfo.
|
||||
*/
|
||||
void
|
||||
cost_gather(GatherPath *path, PlannerInfo *root,
|
||||
RelOptInfo *rel, ParamPathInfo *param_info)
|
||||
RelOptInfo *rel, ParamPathInfo *param_info,
|
||||
double *rows)
|
||||
{
|
||||
Cost startup_cost = 0;
|
||||
Cost run_cost = 0;
|
||||
|
||||
/* Mark the path with the correct row estimate */
|
||||
if (param_info)
|
||||
if (rows)
|
||||
path->path.rows = *rows;
|
||||
else if (param_info)
|
||||
path->path.rows = param_info->ppi_rows;
|
||||
else
|
||||
path->path.rows = rel->rows;
|
||||
@@ -1751,6 +1757,8 @@ cost_agg(Path *path, PlannerInfo *root,
|
||||
{
|
||||
/* must be AGG_HASHED */
|
||||
startup_cost = input_total_cost;
|
||||
if (!enable_hashagg)
|
||||
startup_cost += disable_cost;
|
||||
startup_cost += aggcosts->transCost.startup;
|
||||
startup_cost += aggcosts->transCost.per_tuple * input_tuples;
|
||||
startup_cost += (cpu_operator_cost * numGroupCols) * input_tuples;
|
||||
|
||||
Reference in New Issue
Block a user