Skip to content

Commit 3fd19a9

Browse files
committed
Minor adjustments to WindowAgg startup cost code
This is a follow-on of 3900a02 containing some changes which I forgot to commit locally before forming a patch with git format-patch. Discussion: https://postgr.es/m/CAApHDvrB0S5BMv+0-wTTqWFE-BJ0noWqTnDu9QQfjZ2VSpLv_g@mail.gmail.com
1 parent 3900a02 commit 3fd19a9

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/backend/optimizer/path/costsize.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,8 +2933,8 @@ get_windowclause_startup_tuples(PlannerInfo *root, WindowClause *wc,
29332933
* NULLs are not allowed, but currently, there's no code to
29342934
* error out if there's a NULL Const. We'll only discover
29352935
* this during execution. For now, just pretend everything is
2936-
* fine and assume that just the current row/range/group will
2937-
* be needed.
2936+
* fine and assume that just the first row/range/group will be
2937+
* needed.
29382938
*/
29392939
end_offset_value = 1.0;
29402940
}
@@ -3055,15 +3055,6 @@ cost_windowagg(Path *path, PlannerInfo *root,
30553055
startup_cost = input_startup_cost;
30563056
total_cost = input_total_cost;
30573057

3058-
/*
3059-
* Estimate how many tuples we'll need to read from the subnode before we
3060-
* can output the first WindowAgg row.
3061-
*/
3062-
startup_tuples = get_windowclause_startup_tuples(root, winclause,
3063-
input_tuples);
3064-
3065-
elog(DEBUG1, "startup_tuples = %g", startup_tuples); /* XXX not for commit */
3066-
30673058
/*
30683059
* Window functions are assumed to cost their stated execution cost, plus
30693060
* the cost of evaluating their input expressions, per tuple. Since they
@@ -3124,6 +3115,9 @@ cost_windowagg(Path *path, PlannerInfo *root,
31243115
* cost of the subnode, so we only need to do this when the estimated
31253116
* startup tuples is above 1.0.
31263117
*/
3118+
startup_tuples = get_windowclause_startup_tuples(root, winclause,
3119+
input_tuples);
3120+
31273121
if (startup_tuples > 1.0)
31283122
path->startup_cost += (total_cost - startup_cost) / input_tuples *
31293123
(startup_tuples - 1.0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy