From: Tom Lane Date: Tue, 11 Oct 2005 16:45:00 +0000 (+0000) Subject: Fix oversight in 8.0 modification of RestrictInfo data structures. X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=eb46010da80f936282a4b7ce6f73f7eb95933264;p=users%2Fbernd%2Fpostgres.git Fix oversight in 8.0 modification of RestrictInfo data structures. A RestrictInfo representing an OR clause now contains two versions of the contained expression, one with sub-RestrictInfos and one without. clause_selectivity() should descend to the version with sub-RestrictInfos so that it has a chance of caching its results for the OR's sub-clauses. Failing to do so resulted in redundant planner effort. --- diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c index c856141997..6094baee24 100644 --- a/src/backend/optimizer/path/clausesel.c +++ b/src/backend/optimizer/path/clausesel.c @@ -461,8 +461,15 @@ clause_selectivity(PlannerInfo *root, } } - /* Proceed with examination of contained clause */ - clause = (Node *) rinfo->clause; + /* + * Proceed with examination of contained clause. If the clause is an + * OR-clause, we want to look at the variant with sub-RestrictInfos, + * so that per-subclause selectivities can be cached. + */ + if (rinfo->orclause) + clause = (Node *) rinfo->orclause; + else + clause = (Node *) rinfo->clause; } if (IsA(clause, Var))