@@ -2933,8 +2933,8 @@ get_windowclause_startup_tuples(PlannerInfo *root, WindowClause *wc,
2933
2933
* NULLs are not allowed, but currently, there's no code to
2934
2934
* error out if there's a NULL Const. We'll only discover
2935
2935
* 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.
2938
2938
*/
2939
2939
end_offset_value = 1.0 ;
2940
2940
}
@@ -3055,15 +3055,6 @@ cost_windowagg(Path *path, PlannerInfo *root,
3055
3055
startup_cost = input_startup_cost ;
3056
3056
total_cost = input_total_cost ;
3057
3057
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
-
3067
3058
/*
3068
3059
* Window functions are assumed to cost their stated execution cost, plus
3069
3060
* the cost of evaluating their input expressions, per tuple. Since they
@@ -3124,6 +3115,9 @@ cost_windowagg(Path *path, PlannerInfo *root,
3124
3115
* cost of the subnode, so we only need to do this when the estimated
3125
3116
* startup tuples is above 1.0.
3126
3117
*/
3118
+ startup_tuples = get_windowclause_startup_tuples (root , winclause ,
3119
+ input_tuples );
3120
+
3127
3121
if (startup_tuples > 1.0 )
3128
3122
path -> startup_cost += (total_cost - startup_cost ) / input_tuples *
3129
3123
(startup_tuples - 1.0 );
0 commit comments