8000 Bugfix. The predicted_cardinality field of a plan node could be · postgrespro/aqo@8651c23 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8651c23

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 e1a7199 commit 8651c23

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

postprocessing.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,14 @@ learnOnPlanState(PlanState *p, void *context)
279279
learn_rows = p->instrument->ntuples / p->instrument->nloops;
280280
}
281281

282-
/* Calculate predicted cardinality */
283-
if (p->plan->predicted_cardinality > 0.)
282+
/*
283+
* Calculate predicted cardinality.
284+
* We could find a positive value of predicted cardinality in the case of
285+
* reusing plan caused by the rewriting procedure.
286+
* Also it may be caused by using of a generic plan.
287+
*/
288+
if (p->plan->predicted_cardinality > 0. && query_context.use_aqo)
284289
{
285-
Assert(query_context.use_aqo);
286-
287290
/* AQO made prediction. use it. */
288291
predicted = p->plan->predicted_cardinality;
289292
}

0 commit comments

Comments
 (0)
0