From c82ca4c15828abdecf0ec5343d7f39b4f3a475f9 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 16 Feb 1999 00:41:03 +0000 Subject: [PATCH] Re-enable bushy plans. Vadim want them. --- src/backend/optimizer/geqo/geqo_eval.c | 12 +++++------ src/backend/optimizer/path/allpaths.c | 21 ++++++------------- src/backend/optimizer/path/joinrels.c | 17 +++++----------- src/backend/optimizer/path/prune.c | 28 +------------------------- src/backend/tcop/postgres.c | 8 ++------ src/include/optimizer/internal.h | 4 +--- src/include/optimizer/paths.h | 4 +++- 7 files changed, 23 insertions(+), 71 deletions(-) diff --git a/src/backend/optimizer/geqo/geqo_eval.c b/src/backend/optimizer/geqo/geqo_eval.c index a109ecc48e..5659e99846 100644 --- a/src/backend/optimizer/geqo/geqo_eval.c +++ b/src/backend/optimizer/geqo/geqo_eval.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_eval.c,v 1.32 1999/02/15 03:22:00 momjian Exp $ + * $Id: geqo_eval.c,v 1.33 1999/02/16 00:40:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -119,14 +119,12 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *out inner_rel->joininfo, inner_rel->relids))) { -#ifdef NOT_USED - if (BushyPlanFlag) + if (!BushyPlanFlag) + new_rels = make_rels_by_clauseless_joins(outer_rel, + lcons(inner_rel,NIL)); + else new_rels = make_rels_by_clauseless_joins(outer_rel, lcons(outer_rel,NIL)); - else -#endif - new_rels = make_rels_by_clauseless_joins(outer_rel, - lcons(inner_rel,NIL)); } /* process new_rel->pathlist */ diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index a57c939edf..90469a63e7 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.39 1999/02/15 05:49:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.40 1999/02/16 00:40:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -203,7 +203,6 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed) rels_set_cheapest(joined_rels); -#ifdef NOT_USED if (BushyPlanFlag) { /* @@ -214,7 +213,6 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed) */ add_rel_to_rel_joininfos(root, joined_rels, rels); } -#endif foreach(x, joined_rels) { @@ -230,35 +228,28 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed) #endif } -#ifdef NOT_USED if (BushyPlanFlag) { /* * prune rels that have been completely incorporated into new * join rels */ - rels = del_rels_all_bushy_inactive(rels); + joined_rels = del_rels_all_bushy_inactive(rels); /* * merge join rels if then contain the same list of base rels */ - joined_rels = merge_rels_with_same_relids(joined_rels, rels); + merge_rels_with_same_relids(joined_rels); } -#endif root->join_rel_list = rels = joined_rels; } -#ifdef NOT_USED Assert(BushyPlanFlag || length(rels) == 1); -#endif - Assert(length(rels) == 1); -#ifdef NOT_USED - if (BushyPlanFlag) - return get_cheapest_complete_rel(rels); + if (!BushyPlanFlag) + return lfirst(rels); else -#endif - return lfirst(rels); + return get_cheapest_complete_rel(rels); } /***************************************************************************** diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index 46a2cbb5cd..8c1bc06e68 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.25 1999/02/15 05:21:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.26 1999/02/16 00:41:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,12 +70,11 @@ make_rels_by_joins(Query *root, List *outer_rels) * Oops, we have a relation that is not joined to any other * relation. Cartesian product time. */ -#ifdef NOT_USED - if (BushyPlanFlag) - joins = make_rels_by_clauseless_joins(outer_rel, outer_rels); + if (!BushyPlanFlag) + joins = make_rels_by_clauseless_joins(outer_rel, + root->base_rel_list); else -#endif - joins = make_rels_by_clauseless_joins(outer_rel, root->base_rel_list); + joins = make_rels_by_clauseless_joins(outer_rel, outer_rels); } join_list = nconc(join_list, joins); @@ -137,14 +136,12 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel, joininfo); } } -#ifdef NOT_USED else if (BushyPlanFlag) { rel = make_join_rel(outer_rel, get_join_rel(root, unjoined_rels), joininfo); } -#endif else rel = NULL; @@ -246,10 +243,8 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo) if (joininfo) { joinrel->restrictinfo = joininfo->jinfo_restrictinfo; -#ifdef NOT_USED if (BushyPlanFlag) joininfo->bushy_inactive = true; -#endif } joinrel_joininfo_list = new_joininfo_list(append(outer_rel->joininfo, inner_rel->joininfo), @@ -471,7 +466,6 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels) } } -#ifdef NOT_USED /* * get_cheapest_complete_rel * Find the join relation that includes all the original @@ -515,7 +509,6 @@ get_cheapest_complete_rel(List *join_rel_list) return final_rel; } -#endif /* * add_superrels diff --git a/src/backend/optimizer/path/prune.c b/src/backend/optimizer/path/prune.c index 3847138345..f0905ae383 100644 --- a/src/backend/optimizer/path/prune.c +++ b/src/backend/optimizer/path/prune.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.35 1999/02/15 05:21:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.36 1999/02/16 00:41:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,31 +106,6 @@ rels_set_cheapest(List *rel_list) } } -#ifdef NOT_USED -/* - * merge_rels_with_same_relids - * Given two lists of rel nodes that are already - * pruned, merge them into one pruned rel node list - * - * 'rel_list1' and - * 'rel_list2' are the rel node lists - * - * Returns one pruned rel node list - */ -List * -merge_rels_with_same_relids(List *rel_list1, List *rel_list2) -{ - List *xrel = NIL; - - foreach(xrel, rel_list1) - { - RelOptInfo *rel = (RelOptInfo *) lfirst(xrel); - - rel_list2 = merge_rel_with_same_relids(rel, rel_list2); - } - return append(rel_list1, rel_list2); -} - /* * del_rels_all_bushy_inactive * If all the joininfo's in a rel node are bushy_inactive, @@ -175,5 +150,4 @@ del_rels_all_bushy_inactive(List *old_rels) } return temp_list; } -#endif diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index adf4ddd43e..329d47bc80 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.100 1999/02/15 03:22:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.101 1999/02/16 00:41:01 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -173,10 +173,8 @@ int UseNewLine = 0; /* Use EOF as query delimiters */ * plans * ---------------- */ -#ifdef NOT_USED int BushyPlanFlag = 0; /* default to false -- consider only * left-deep trees */ -#endif /* ** Flags for expensive function optimization -- JMH 3/9/92 @@ -1043,7 +1041,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) #endif break; -#ifdef NOT_USED case 'b': /* ---------------- * set BushyPlanFlag to true. @@ -1051,7 +1048,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) */ BushyPlanFlag = 1; break; -#endif case 'B': /* ---------------- @@ -1542,7 +1538,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.100 $ $Date: 1999/02/15 03:22:21 $\n"); + puts("$Revision: 1.101 $ $Date: 1999/02/16 00:41:01 $\n"); } /* ---------------- diff --git a/src/include/optimizer/internal.h b/src/include/optimizer/internal.h index c372e63e5d..746ec87eae 100644 --- a/src/include/optimizer/internal.h +++ b/src/include/optimizer/internal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: internal.h,v 1.15 1999/02/15 03:22:31 momjian Exp $ + * $Id: internal.h,v 1.16 1999/02/16 00:41:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,9 +80,7 @@ #define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE) #define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0)) -#ifdef NOT_USED extern int BushyPlanFlag; -#endif /* #define deactivate_joininfo(joininfo) joininfo->inactive=true*/ /*#define joininfo_inactive(joininfo) joininfo->inactive */ diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 8f1b7873d2..4e1bfe3323 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: paths.h,v 1.19 1999/02/15 05:28:10 momjian Exp $ + * $Id: paths.h,v 1.20 1999/02/16 00:41:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -85,11 +85,13 @@ extern List *make_rels_by_clauseless_joins(RelOptInfo *outer_rel, List *inner_rels); extern RelOptInfo *make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo); extern List *new_join_tlist(List *tlist, List *other_relids,int first_resdomno); +extern RelOptInfo *get_cheapest_complete_rel(List *join_rel_list); /* * prototypes for path/prune.c */ extern void merge_rels_with_same_relids(List *rel_list); extern void rels_set_cheapest(List *rel_list); +extern List *del_rels_all_bushy_inactive(List *old_rels); #endif /* PATHS_H */