|
49 | 49 | * Portions Copyright (c) 1994, Regents of the University of California
|
50 | 50 | *
|
51 | 51 | * IDENTIFICATION
|
52 |
| - * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.125 2004/02/17 00:52:53 tgl Exp $ |
| 52 | + * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.126 2004/04/06 18:46:03 tgl Exp $ |
53 | 53 | *
|
54 | 54 | *-------------------------------------------------------------------------
|
55 | 55 | */
|
@@ -918,23 +918,31 @@ cost_mergejoin(MergePath *path, Query *root)
|
918 | 918 | * all mergejoin paths associated with the merge clause, we cache the
|
919 | 919 | * results in the RestrictInfo node.
|
920 | 920 | */
|
921 |
| - firstclause = (RestrictInfo *) lfirst(mergeclauses); |
922 |
| - if (firstclause->left_mergescansel < 0) /* not computed yet? */ |
923 |
| - mergejoinscansel(root, (Node *) firstclause->clause, |
924 |
| - &firstclause->left_mergescansel, |
925 |
| - &firstclause->right_mergescansel); |
926 |
| - |
927 |
| - if (bms_is_subset(firstclause->left_relids, outer_path->parent->relids)) |
| 921 | + if (mergeclauses) |
928 | 922 | {
|
929 |
| - /* left side of clause is outer */ |
930 |
| - outerscansel = firstclause->left_mergescansel; |
931 |
| - innerscansel = firstclause->right_mergescansel; |
| 923 | + firstclause = (RestrictInfo *) lfirst(mergeclauses); |
| 924 | + if (firstclause->left_mergescansel < 0) /* not computed yet? */ |
| 925 | + mergejoinscansel(root, (Node *) firstclause->clause, |
| 926 | + &firstclause->left_mergescansel, |
| 927 | + &firstclause->right_mergescansel); |
| 928 | + |
| 929 | + if (bms_is_subset(firstclause->left_relids, outer_path->parent->relids)) |
| 930 | + { |
| 931 | + /* left side of clause is outer */ |
| 932 | + outerscansel = firstclause->left_mergescansel; |
| 933 | + innerscansel = firstclause->right_mergescansel; |
| 934 | + } |
| 935 | + else |
| 936 | + { |
| 937 | + /* left side of clause is inner */ |
| 938 | + outerscansel = firstclause->right_mergescansel; |
| 939 | + innerscansel = firstclause->left_mergescansel; |
| 940 | + } |
932 | 941 | }
|
933 | 942 | else
|
934 | 943 | {
|
935 |
| - /* left side of clause is inner */ |
936 |
| - outerscansel = firstclause->right_mergescansel; |
937 |
| - innerscansel = firstclause->left_mergescansel; |
| 944 | + /* cope with clauseless mergejoin */ |
| 945 | + outerscansel = innerscansel = 1.0; |
938 | 946 | }
|
939 | 947 |
|
940 | 948 | /* convert selectivity to row count; must scan at least one row */
|
|
0 commit comments