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

Commit 73e3edf

Browse files
committed
Push subplan clauses to the back in qual lists for join plans, not
only scan plans. Per observation from Rod Taylor.
1 parent 147c164 commit 73e3edf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/backend/optimizer/plan/createplan.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.155 2003/08/17 19:58:05 tgl Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.156 2003/08/26 22:56:51 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -944,6 +944,10 @@ create_nestloop_plan(Query *root,
944944
otherclauses = NIL;
945945
}
946946

947+
/* Sort clauses into best execution order */
948+
joinclauses = order_qual_clauses(root, joinclauses);
949+
otherclauses = order_qual_clauses(root, otherclauses);
950+
947951
join_plan = make_nestloop(tlist,
948952
joinclauses,
949953
otherclauses,
@@ -995,6 +999,11 @@ create_mergejoin_plan(Query *root,
995999
mergeclauses = get_switched_clauses(best_path->path_mergeclauses,
9961000
best_path->jpath.outerjoinpath->parent->relids);
9971001

1002+
/* Sort clauses into best execution order */
1003+
joinclauses = order_qual_clauses(root, joinclauses);
1004+
otherclauses = order_qual_clauses(root, otherclauses);
1005+
mergeclauses = order_qual_clauses(root, mergeclauses);
1006+
9981007
/*
9991008
* Create explicit sort nodes for the outer and inner join paths if
10001009
* necessary. The sort cost was already accounted for in the path.
@@ -1078,6 +1087,11 @@ create_hashjoin_plan(Query *root,
10781087
hashclauses = get_switched_clauses(best_path->path_hashclauses,
10791088
best_path->jpath.outerjoinpath->parent->relids);
10801089

1090+
/* Sort clauses into best execution order */
1091+
joinclauses = order_qual_clauses(root, joinclauses);
1092+
otherclauses = order_qual_clauses(root, otherclauses);
1093+
hashclauses = order_qual_clauses(root, hashclauses);
1094+
10811095
/*
10821096
* Extract the inner hash keys (right-hand operands of the
10831097
* hashclauses) to put in the Hash node.

0 commit comments

Comments
 (0)