diff options
Diffstat (limited to 'src/backend/optimizer/path/costsize.c')
-rw-r--r-- | src/backend/optimizer/path/costsize.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 4b500bc03a5..c151ddd5f16 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -49,7 +49,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.115.2.1 2003/12/03 17:45:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.115.2.2 2004/04/06 18:46:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -928,23 +928,31 @@ cost_mergejoin(MergePath *path, Query *root) * all mergejoin paths associated with the merge clause, we cache the * results in the RestrictInfo node. */ - firstclause = (RestrictInfo *) lfirst(mergeclauses); - if (firstclause->left_mergescansel < 0) /* not computed yet? */ - mergejoinscansel(root, (Node *) firstclause->clause, - &firstclause->left_mergescansel, - &firstclause->right_mergescansel); - - if (bms_is_subset(firstclause->left_relids, outer_path->parent->relids)) + if (mergeclauses) { - /* left side of clause is outer */ - outerscansel = firstclause->left_mergescansel; - innerscansel = firstclause->right_mergescansel; + firstclause = (RestrictInfo *) lfirst(mergeclauses); + if (firstclause->left_mergescansel < 0) /* not computed yet? */ + mergejoinscansel(root, (Node *) firstclause->clause, + &firstclause->left_mergescansel, + &firstclause->right_mergescansel); + + if (bms_is_subset(firstclause->left_relids, outer_path->parent->relids)) + { + /* left side of clause is outer */ + outerscansel = firstclause->left_mergescansel; + innerscansel = firstclause->right_mergescansel; + } + else + { + /* left side of clause is inner */ + outerscansel = firstclause->right_mergescansel; + innerscansel = firstclause->left_mergescansel; + } } else { - /* left side of clause is inner */ - outerscansel = firstclause->right_mergescansel; - innerscansel = firstclause->left_mergescansel; + /* cope with clauseless mergejoin */ + outerscansel = innerscansel = 1.0; } /* convert selectivity to row count; must scan at least one row */ |