From: Tom Lane Date: Mon, 16 Apr 2001 19:44:10 +0000 (+0000) Subject: Avoid reversing user-given order of WHERE clauses while attaching clauses X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=6fbc8cd9e12265b54bc8c266bfde870bf16e9cd7;p=users%2Fbernd%2Fpostgres.git Avoid reversing user-given order of WHERE clauses while attaching clauses to specific base or join RelOptInfo nodes during planning. This preserves the more-intuitive behavior of 7.0.* --- if you write an expensive clause (such as a sub-select) last, it should get evaluated last. Someday we ought to try to have some intelligence about the order of evaluation of WHERE clauses, but for now we should not override what the user wrote. --- diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index a81973767d..bc778930a2 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -444,8 +444,8 @@ distribute_qual_to_rels(Query *root, Node *clause, */ RelOptInfo *rel = get_base_rel(root, lfirsti(relids)); - rel->baserestrictinfo = lcons(restrictinfo, - rel->baserestrictinfo); + rel->baserestrictinfo = lappend(rel->baserestrictinfo, + restrictinfo); /* * Check for a "mergejoinable" clause even though it's not a join @@ -549,8 +549,8 @@ add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, */ joininfo = find_joininfo_node(get_base_rel(root, cur_relid), unjoined_relids); - joininfo->jinfo_restrictinfo = lcons(restrictinfo, - joininfo->jinfo_restrictinfo); + joininfo->jinfo_restrictinfo = lappend(joininfo->jinfo_restrictinfo, + restrictinfo); } }