Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f4dcaab

Browse files
committed
Bugfix. The predicted_cardinality field of a plan node could be
established by previous execution of this plan in another query.
1 parent d0afdc1 commit f4dcaab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

postprocessing.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,13 @@ learnOnPlanState(PlanState *p, void *context)
304304
* to calculate produced rows. */
305305
learn_rows = p->instrument->ntuples / p->instrument->nloops;
306306

307-
if (p->plan->predicted_cardinality > 0.)
307+
/*
308+
* Calculate predicted cardinality.
309+
* We could find a positive value of predicted cardinality in
310+
* the case of reusing plan caused by the rewriting procedure.
311+
* Also it may be caused by using of a generic plan.
312+
*/
313+
if (p->plan->predicted_cardinality > 0. && query_context.use_aqo)
308314
predicted = p->plan->predicted_cardinality;
309315
else if (IsParallelTuplesProcessing(p->plan))
310316
predicted = p->plan->plan_rows *

0 commit comments

Comments
 (0)