Commit 73e3edf2 authored by Tom Lane's avatar Tom Lane

Push subplan clauses to the back in qual lists for join plans, not

only scan plans.  Per observation from Rod Taylor.
parent 147c1649
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.155 2003/08/17 19:58:05 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.156 2003/08/26 22:56:51 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -944,6 +944,10 @@ create_nestloop_plan(Query *root, ...@@ -944,6 +944,10 @@ create_nestloop_plan(Query *root,
otherclauses = NIL; otherclauses = NIL;
} }
/* Sort clauses into best execution order */
joinclauses = order_qual_clauses(root, joinclauses);
otherclauses = order_qual_clauses(root, otherclauses);
join_plan = make_nestloop(tlist, join_plan = make_nestloop(tlist,
joinclauses, joinclauses,
otherclauses, otherclauses,
...@@ -995,6 +999,11 @@ create_mergejoin_plan(Query *root, ...@@ -995,6 +999,11 @@ create_mergejoin_plan(Query *root,
mergeclauses = get_switched_clauses(best_path->path_mergeclauses, mergeclauses = get_switched_clauses(best_path->path_mergeclauses,
best_path->jpath.outerjoinpath->parent->relids); best_path->jpath.outerjoinpath->parent->relids);
/* Sort clauses into best execution order */
joinclauses = order_qual_clauses(root, joinclauses);
otherclauses = order_qual_clauses(root, otherclauses);
mergeclauses = order_qual_clauses(root, mergeclauses);
/* /*
* Create explicit sort nodes for the outer and inner join paths if * Create explicit sort nodes for the outer and inner join paths if
* necessary. The sort cost was already accounted for in the path. * necessary. The sort cost was already accounted for in the path.
...@@ -1078,6 +1087,11 @@ create_hashjoin_plan(Query *root, ...@@ -1078,6 +1087,11 @@ create_hashjoin_plan(Query *root,
hashclauses = get_switched_clauses(best_path->path_hashclauses, hashclauses = get_switched_clauses(best_path->path_hashclauses,
best_path->jpath.outerjoinpath->parent->relids); best_path->jpath.outerjoinpath->parent->relids);
/* Sort clauses into best execution order */
joinclauses = order_qual_clauses(root, joinclauses);
otherclauses = order_qual_clauses(root, otherclauses);
hashclauses = order_qual_clauses(root, hashclauses);
/* /*
* Extract the inner hash keys (right-hand operands of the * Extract the inner hash keys (right-hand operands of the
* hashclauses) to put in the Hash node. * hashclauses) to put in the Hash node.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment