From f5e83662d06a40f90ceb3516fc88674eb6c1e4f9 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 24 Jan 2003 03:58:44 +0000 Subject: Modify planner's implied-equality-deduction code so that when a set of known-equal expressions includes any constant expressions (including Params from outer queries), we actively suppress any 'var = var' clauses that are or could be deduced from the set, generating only the deducible 'var = const' clauses instead. The idea here is to push down the restrictions implied by the equality set to base relations whenever possible. Once we have applied the 'var = const' clauses, the 'var = var' clauses are redundant, and should be suppressed both to save work at execution and to avoid double-counting restrictivity. --- src/backend/optimizer/util/relnode.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/backend/optimizer/util/relnode.c') diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index 144fac75501..06a73bf4e9e 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.44 2003/01/20 18:54:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.45 2003/01/24 03:58:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -549,14 +549,19 @@ subbuild_joinrel_joinlist(RelOptInfo *joinrel, /* * These clauses are still join clauses at this level, so find * or make the appropriate JoinInfo item for the joinrel, and - * add the clauses to it (eliminating duplicates). + * add the clauses to it, eliminating duplicates. (Since + * RestrictInfo nodes are normally multiply-linked rather than + * copied, pointer equality should be a sufficient test. If + * two equal() nodes should happen to sneak in, no great harm + * is done --- they'll be detected by redundant-clause testing + * when they reach a restriction list.) */ JoinInfo *new_joininfo; new_joininfo = make_joininfo_node(joinrel, new_unjoined_relids); new_joininfo->jinfo_restrictinfo = - set_union(new_joininfo->jinfo_restrictinfo, - joininfo->jinfo_restrictinfo); + set_ptrUnion(new_joininfo->jinfo_restrictinfo, + joininfo->jinfo_restrictinfo); } } } -- cgit v1.2.3