Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit974e3cf

Browse files
committed
cost_agg really ought to charge something per output tuple; else there
are cases where it appears to have zero run cost.
1 parent4e5fbb3 commit974e3cf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎src/backend/optimizer/path/costsize.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* Portions Copyright (c) 1994, Regents of the University of California
5050
*
5151
* IDENTIFICATION
52-
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.146 2005/06/05 22:32:55 tgl Exp $
52+
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.147 2005/08/27 22:37:00 tgl Exp $
5353
*
5454
*-------------------------------------------------------------------------
5555
*/
@@ -872,7 +872,7 @@ cost_agg(Path *path, PlannerInfo *root,
872872
* for grouping comparisons.
873873
*
874874
* We will produce a single output tuple if not grouping, and a tuple per
875-
* group otherwise.
875+
* group otherwise. We charge cpu_tuple_cost for each output tuple.
876876
*
877877
* Note: in this cost model, AGG_SORTED and AGG_HASHED have exactly the
878878
* same total CPU cost, but AGG_SORTED has lower startup cost.If the
@@ -888,7 +888,7 @@ cost_agg(Path *path, PlannerInfo *root,
888888
startup_cost=input_total_cost;
889889
startup_cost+=cpu_operator_cost* (input_tuples+1)*numAggs;
890890
/* we aren't grouping */
891-
total_cost=startup_cost;
891+
total_cost=startup_cost+cpu_tuple_cost;
892892
}
893893
elseif (aggstrategy==AGG_SORTED)
894894
{
@@ -899,6 +899,7 @@ cost_agg(Path *path, PlannerInfo *root,
899899
total_cost+=cpu_operator_cost*input_tuples*numGroupCols;
900900
total_cost+=cpu_operator_cost*input_tuples*numAggs;
901901
total_cost+=cpu_operator_cost*numGroups*numAggs;
902+
total_cost+=cpu_tuple_cost*numGroups;
902903
}
903904
else
904905
{
@@ -908,6 +909,7 @@ cost_agg(Path *path, PlannerInfo *root,
908909
startup_cost+=cpu_operator_cost*input_tuples*numAggs;
909910
total_cost=startup_cost;
910911
total_cost+=cpu_operator_cost*numGroups*numAggs;
912+
total_cost+=cpu_tuple_cost*numGroups;
911913
}
912914

913915
path->startup_cost=startup_cost;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp