diff options
| author | Tom Lane | 2003-01-24 03:58:44 +0000 |
|---|---|---|
| committer | Tom Lane | 2003-01-24 03:58:44 +0000 |
| commit | f5e83662d06a40f90ceb3516fc88674eb6c1e4f9 (patch) | |
| tree | 5b682c9bcbc9dd88b7bcc19f1ca1bf43c8335a83 /src/include | |
| parent | ef7422510e93266e5aa9bb926d6747d5f2ae21f4 (diff) | |
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.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/pg_list.h | 3 | ||||
| -rw-r--r-- | src/include/optimizer/joininfo.h | 14 | ||||
| -rw-r--r-- | src/include/optimizer/paths.h | 4 | ||||
| -rw-r--r-- | src/include/optimizer/planmain.h | 10 |
4 files changed, 22 insertions, 9 deletions
diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index d3b01b7fed0..56a66409161 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_list.h,v 1.31 2003/01/20 18:55:04 tgl Exp $ + * $Id: pg_list.h,v 1.32 2003/01/24 03:58:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -141,6 +141,7 @@ extern List *set_differencei(List *list1, List *list2); extern List *lreverse(List *l); extern List *set_union(List *list1, List *list2); extern List *set_unioni(List *list1, List *list2); +extern List *set_ptrUnion(List *list1, List *list2); extern List *set_intersecti(List *list1, List *list2); extern bool equali(List *list1, List *list2); diff --git a/src/include/optimizer/joininfo.h b/src/include/optimizer/joininfo.h index 37131b722d2..6fd806bbaf1 100644 --- a/src/include/optimizer/joininfo.h +++ b/src/include/optimizer/joininfo.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: joininfo.h,v 1.22 2003/01/20 18:55:04 tgl Exp $ + * $Id: joininfo.h,v 1.23 2003/01/24 03:58:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,15 @@ #include "nodes/relation.h" -extern JoinInfo *find_joininfo_node(RelOptInfo *this_rel, List *join_relids); -extern JoinInfo *make_joininfo_node(RelOptInfo *this_rel, List *join_relids); + +extern JoinInfo *find_joininfo_node(RelOptInfo *this_rel, Relids join_relids); +extern JoinInfo *make_joininfo_node(RelOptInfo *this_rel, Relids join_relids); + +extern void add_join_clause_to_rels(Query *root, + RestrictInfo *restrictinfo, + Relids join_relids); +extern void remove_join_clause_from_rels(Query *root, + RestrictInfo *restrictinfo, + Relids join_relids); #endif /* JOININFO_H */ diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 7ed5b403a87..76285bac408 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: paths.h,v 1.63 2002/12/16 21:30:30 tgl Exp $ + * $Id: paths.h,v 1.64 2003/01/24 03:58:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,6 +17,7 @@ #include "nodes/relation.h" + /* default GEQO threshold (default value for geqo_rels) */ /* If you change this, update backend/utils/misc/postgresql.sample.conf */ #define DEFAULT_GEQO_RELS 11 @@ -92,6 +93,7 @@ typedef enum } PathKeysComparison; extern void add_equijoined_keys(Query *root, RestrictInfo *restrictinfo); +extern bool exprs_known_equal(Query *root, Node *item1, Node *item2); extern void generate_implied_equalities(Query *root); extern List *canonicalize_pathkeys(Query *root, List *pathkeys); extern PathKeysComparison compare_pathkeys(List *keys1, List *keys2); diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index cf9c2ddeb64..399b3bb1310 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: planmain.h,v 1.67 2003/01/20 18:55:05 tgl Exp $ + * $Id: planmain.h,v 1.68 2003/01/24 03:58:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -57,9 +57,11 @@ extern Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan); extern void add_base_rels_to_query(Query *root, Node *jtnode); extern void build_base_rel_tlists(Query *root, List *tlist); extern Relids distribute_quals_to_rels(Query *root, Node *jtnode); -extern void process_implied_equality(Query *root, Node *item1, Node *item2, - Oid sortop1, Oid sortop2); -extern bool exprs_known_equal(Query *root, Node *item1, Node *item2); +extern void process_implied_equality(Query *root, + Node *item1, Node *item2, + Oid sortop1, Oid sortop2, + Relids item1_relids, Relids item2_relids, + bool delete_it); /* * prototypes for plan/setrefs.c |
