Commit ba2883b2 authored by Bruce Momjian's avatar Bruce Momjian

Remove duplicate geqo functions, and more optimizer cleanup

parent 944d3c39
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.70 1999/02/13 23:15:53 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.71 1999/02/15 03:21:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1420,7 +1420,7 @@ _copyMergeInfo(MergeInfo *from) ...@@ -1420,7 +1420,7 @@ _copyMergeInfo(MergeInfo *from)
* ---------------- * ----------------
*/ */
static JoinInfo * static JoinInfo *
_copyJoinInfo(JoinInfo * from) _copyJoinInfo(JoinInfo *from)
{ {
JoinInfo *newnode = makeNode(JoinInfo); JoinInfo *newnode = makeNode(JoinInfo);
...@@ -1433,7 +1433,7 @@ _copyJoinInfo(JoinInfo * from) ...@@ -1433,7 +1433,7 @@ _copyJoinInfo(JoinInfo * from)
newnode->mergejoinable = from->mergejoinable; newnode->mergejoinable = from->mergejoinable;
newnode->hashjoinable = from->hashjoinable; newnode->hashjoinable = from->hashjoinable;
newnode->inactive = from->inactive; newnode->bushy_inactive = from->bushy_inactive;
return newnode; return newnode;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.32 1999/02/13 23:15:55 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.33 1999/02/15 03:21:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -522,7 +522,7 @@ _equalSubPlan(SubPlan *a, SubPlan *b) ...@@ -522,7 +522,7 @@ _equalSubPlan(SubPlan *a, SubPlan *b)
} }
static bool static bool
_equalJoinInfo(JoinInfo * a, JoinInfo * b) _equalJoinInfo(JoinInfo *a, JoinInfo *b)
{ {
Assert(IsA(a, JoinInfo)); Assert(IsA(a, JoinInfo));
Assert(IsA(b, JoinInfo)); Assert(IsA(b, JoinInfo));
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.10 1999/02/13 23:15:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.11 1999/02/15 03:21:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1018,7 +1018,7 @@ _freeMergeInfo(MergeInfo *node) ...@@ -1018,7 +1018,7 @@ _freeMergeInfo(MergeInfo *node)
* ---------------- * ----------------
*/ */
static void static void
_freeJoinInfo(JoinInfo * node) _freeJoinInfo(JoinInfo *node)
{ {
/* ---------------- /* ----------------
* free remainder of node * free remainder of node
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: outfuncs.c,v 1.72 1999/02/13 23:15:59 momjian Exp $ * $Id: outfuncs.c,v 1.73 1999/02/15 03:21:59 momjian Exp $
* *
* NOTES * NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which * Every (plan) node in POSTGRES has an associated "out" routine which
...@@ -1196,7 +1196,7 @@ _outHashInfo(StringInfo str, HashInfo *node) ...@@ -1196,7 +1196,7 @@ _outHashInfo(StringInfo str, HashInfo *node)
* JoinInfo is a subclass of Node. * JoinInfo is a subclass of Node.
*/ */
static void static void
_outJoinInfo(StringInfo str, JoinInfo * node) _outJoinInfo(StringInfo str, JoinInfo *node)
{ {
appendStringInfo(str, " JINFO :otherrels "); appendStringInfo(str, " JINFO :otherrels ");
_outIntList(str, node->otherrels); _outIntList(str, node->otherrels);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $Id: Makefile,v 1.10 1998/04/06 00:23:07 momjian Exp $ # $Id: Makefile,v 1.11 1999/02/15 03:22:00 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -19,7 +19,7 @@ CFLAGS+= -Wno-error ...@@ -19,7 +19,7 @@ CFLAGS+= -Wno-error
endif endif
OBJS = geqo_copy.o geqo_eval.o geqo_main.o geqo_misc.o \ OBJS = geqo_copy.o geqo_eval.o geqo_main.o geqo_misc.o \
geqo_params.o geqo_paths.o geqo_pool.o geqo_recombination.o \ geqo_params.o geqo_pool.o geqo_recombination.o \
geqo_selection.o \ geqo_selection.o \
geqo_erx.o geqo_pmx.o geqo_cx.o geqo_px.o geqo_ox1.o geqo_ox2.o geqo_erx.o geqo_pmx.o geqo_cx.o geqo_px.o geqo_ox1.o geqo_ox2.o
......
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: geqo_params.c,v 1.13 1999/02/13 23:16:10 momjian Exp $ * $Id: geqo_params.c,v 1.14 1999/02/15 03:22:01 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
static int gimme_pool_size(int string_length); static int gimme_pool_size(int string_length);
static int gimme_number_generations(int pool_size, int effort); static int gimme_number_generations(int pool_size, int effort);
static int next_token(FILE *, char *, int); static int next_token(FILE *, char *, int);
static double geqo_log(double x, double b);
/* /*
* geqo_param * geqo_param
...@@ -338,3 +339,9 @@ gimme_number_generations(int pool_size, int effort) ...@@ -338,3 +339,9 @@ gimme_number_generations(int pool_size, int effort)
return effort * number_gens; return effort * number_gens;
} }
static double
geqo_log(double x, double b)
{
return (log(x) / log(b));
}
/*-------------------------------------------------------------------------
*
* geqo_paths.c
* Routines to process redundant paths and relations
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: geqo_paths.c,v 1.21 1999/02/15 02:04:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "nodes/pg_list.h"
#include "nodes/relation.h"
#include "nodes/primnodes.h"
#include "utils/palloc.h"
#include "utils/elog.h"
#include "optimizer/internal.h"
#include "optimizer/paths.h"
#include "optimizer/pathnode.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/geqo_paths.h"
static List *geqo_prune_rel(RelOptInfo *rel, List *other_rels);
/*
* geqo_prune_rels
* Removes any redundant relation entries from a list of rel nodes
* 'rel_list'.
*
* Returns the resulting list.
*
*/
List *
geqo_prune_rels(List *rel_list)
{
List *temp_list = NIL;
if (rel_list != NIL)
{
temp_list = lcons(lfirst(rel_list),
geqo_prune_rels(geqo_prune_rel((RelOptInfo *) lfirst(rel_list),
lnext(rel_list))));
}
return temp_list;
}
/*
* geqo_prune_rel
* Prunes those relations from 'other_rels' that are redundant with
* 'rel'. A relation is redundant if it is built up of the same
* relations as 'rel'. Paths for the redundant relation are merged into
* the pathlist of 'rel'.
*
* Returns a list of non-redundant relations, and sets the pathlist field
* of 'rel' appropriately.
*
*/
static List *
geqo_prune_rel(RelOptInfo *rel, List *other_rels)
{
List *t_list = NIL;
List *i;
RelOptInfo *other_rel;
foreach(i, other_rels)
{
other_rel = (RelOptInfo *) lfirst(i);
if (same(rel->relids, other_rel->relids))
{
rel->pathlist = add_pathlist(rel,
rel->pathlist,
other_rel->pathlist);
}
else
{
t_list = lappend(t_list, other_rel);
}
}
return t_list;
}
/*
* geqo_set_cheapest
* For a relation 'rel' (which corresponds to a join
* relation), set pointers to the cheapest path
*/
void
geqo_set_cheapest(RelOptInfo *rel)
{
JoinPath *cheapest = (JoinPath *)set_cheapest(rel, rel->pathlist);
if (IsA_JoinPath(cheapest))
rel->size = compute_joinrel_size(cheapest);
else
rel->size = 0;
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.34 1999/02/14 05:27:11 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.35 1999/02/15 03:22:03 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -44,7 +44,7 @@ int32 _use_geqo_rels_ = GEQO_RELS; ...@@ -44,7 +44,7 @@ int32 _use_geqo_rels_ = GEQO_RELS;
static void find_base_rel_paths(Query *root, List *rels); static void find_base_rel_paths(Query *root, List *rels);
static List *find_join_paths(Query *root, List *outer_rels, int levels_needed); static RelOptInfo *make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed);
#ifdef OPTIMIZER_DEBUG #ifdef OPTIMIZER_DEBUG
static void debug_print_rel(Query *root, RelOptInfo *rel); static void debug_print_rel(Query *root, RelOptInfo *rel);
...@@ -52,14 +52,14 @@ static void debug_print_rel(Query *root, RelOptInfo *rel); ...@@ -52,14 +52,14 @@ static void debug_print_rel(Query *root, RelOptInfo *rel);
#endif #endif
/* /*
* find_paths * make_one_rel
* Finds all possible access paths for executing a query, returning the * Finds all possible access paths for executing a query, returning a
* top level list of relation entries. * single rel.
* *
* 'rels' is the list of single relation entries appearing in the query * 'rels' is the list of single relation entries appearing in the query
*/ */
List * RelOptInfo *
find_paths(Query *root, List *rels) make_one_rel(Query *root, List *rels)
{ {
int levels_needed; int levels_needed;
...@@ -69,7 +69,7 @@ find_paths(Query *root, List *rels) ...@@ -69,7 +69,7 @@ find_paths(Query *root, List *rels)
levels_needed = length(rels); levels_needed = length(rels);
if (levels_needed <= 0) if (levels_needed <= 0)
return NIL; return NULL;
find_base_rel_paths(root, rels); find_base_rel_paths(root, rels);
...@@ -78,7 +78,7 @@ find_paths(Query *root, List *rels) ...@@ -78,7 +78,7 @@ find_paths(Query *root, List *rels)
/* /*
* Unsorted single relation, no more processing is required. * Unsorted single relation, no more processing is required.
*/ */
return rels; return lfirst(rels);
} }
else else
{ {
...@@ -88,7 +88,7 @@ find_paths(Query *root, List *rels) ...@@ -88,7 +88,7 @@ find_paths(Query *root, List *rels)
*/ */
set_rest_relselec(root, rels); set_rest_relselec(root, rels);
return find_join_paths(root, rels, levels_needed); return make_one_rel_by_joins(root, rels, levels_needed);
} }
} }
...@@ -142,7 +142,7 @@ find_base_rel_paths(Query *root, List *rels) ...@@ -142,7 +142,7 @@ find_base_rel_paths(Query *root, List *rels)
} }
/* /*
* find_join_paths * make_one_rel_by_joins
* Find all possible joinpaths for a query by successively finding ways * Find all possible joinpaths for a query by successively finding ways
* to join single relations into join relations. * to join single relations into join relations.
* *
...@@ -158,8 +158,8 @@ find_base_rel_paths(Query *root, List *rels) ...@@ -158,8 +158,8 @@ find_base_rel_paths(Query *root, List *rels)
* Returns the final level of join relations, i.e., the relation that is * Returns the final level of join relations, i.e., the relation that is
* the result of joining all the original relations together. * the result of joining all the original relations together.
*/ */
static List * static RelOptInfo *
find_join_paths(Query *root, List *outer_rels, int levels_needed) make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
{ {
List *x; List *x;
List *joined_rels = NIL; List *joined_rels = NIL;
...@@ -170,7 +170,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed) ...@@ -170,7 +170,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
* <utesch@aut.tu-freiberg.de> * * <utesch@aut.tu-freiberg.de> *
*******************************************/ *******************************************/
if ((_use_geqo_) && length(root->base_rel_list) >= _use_geqo_rels_) if ((_use_geqo_) && length(root->base_rel_list) >= _use_geqo_rels_)
return lcons(geqo(root), NIL); /* returns *one* Rel, so lcons it */ return geqo(root);
/******************************************* /*******************************************
* rest will be deprecated in case of GEQO * * rest will be deprecated in case of GEQO *
...@@ -184,7 +184,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed) ...@@ -184,7 +184,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
* modify 'joined_rels' accordingly, then eliminate redundant join * modify 'joined_rels' accordingly, then eliminate redundant join
* relations. * relations.
*/ */
joined_rels = make_new_rels_by_joins(root, outer_rels); joined_rels = make_rels_by_joins(root, outer_rels);
update_rels_pathlist_for_joins(root, joined_rels); update_rels_pathlist_for_joins(root, joined_rels);
...@@ -202,9 +202,9 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed) ...@@ -202,9 +202,9 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
rels_set_cheapest(joined_rels); rels_set_cheapest(joined_rels);
#ifdef NOT_USED
if (BushyPlanFlag) if (BushyPlanFlag)
{ {
/* /*
* In case of bushy trees if there is still a join between a * In case of bushy trees if there is still a join between a
* join relation and another relation, add a new joininfo that * join relation and another relation, add a new joininfo that
...@@ -213,6 +213,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed) ...@@ -213,6 +213,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
*/ */
add_new_joininfos(root, joined_rels, outer_rels); add_new_joininfos(root, joined_rels, outer_rels);
} }
#endif
foreach(x, joined_rels) foreach(x, joined_rels)
{ {
...@@ -228,6 +229,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed) ...@@ -228,6 +229,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
#endif #endif
} }
#ifdef NOT_USED
if (BushyPlanFlag) if (BushyPlanFlag)
{ {
/* /*
...@@ -243,16 +245,24 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed) ...@@ -243,16 +245,24 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
root->join_rel_list = outer_rels; root->join_rel_list = outer_rels;
} }
else else
root->join_rel_list = joined_rels; #endif
root->join_rel_list = joined_rels;
#ifdef NOT_USED
if (!BushyPlanFlag) if (!BushyPlanFlag)
outer_rels = joined_rels; #endif
outer_rels = joined_rels;
} }
Assert(length(joined_rels) == 1);
#ifdef NOT_USED
if (BushyPlanFlag) if (BushyPlanFlag)
return final_join_rels(outer_rels); return final_join_rels(outer_rels);
else else
return joined_rels; #endif
return lfirst(joined_rels);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.32 1999/02/13 23:16:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.33 1999/02/15 03:22:04 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -440,21 +440,19 @@ compute_joinrel_size(JoinPath *joinpath) ...@@ -440,21 +440,19 @@ compute_joinrel_size(JoinPath *joinpath)
Cost temp = 1.0; Cost temp = 1.0;
int temp1 = 0; int temp1 = 0;
/* cartesian product */
temp *= ((Path *) joinpath->outerjoinpath)->parent->size; temp *= ((Path *) joinpath->outerjoinpath)->parent->size;
temp *= ((Path *) joinpath->innerjoinpath)->parent->size; temp *= ((Path *) joinpath->innerjoinpath)->parent->size;
temp = temp * product_selec(joinpath->pathinfo); temp = temp * product_selec(joinpath->pathinfo);
if (temp >= (MAXINT - 1)) if (temp >= (MAXINT-1)/2)
temp1 = MAXINT;
else
{ {
/* if we exceed (MAXINT-1)/2, we switch to log scale */
/* /* +1 prevents log(0) */
* should be ceil here, we don't want joinrel size's of one, do temp1 = ceil(log(temp + 1 - (MAXINT-1)/2) + (MAXINT-1)/2);
* we?
*/
temp1 = ceil((double) temp);
} }
else
temp1 = ceil((double) temp);
Assert(temp1 >= 0); Assert(temp1 >= 0);
return temp1; return temp1;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.46 1999/02/15 02:04:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.47 1999/02/15 03:22:05 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1302,13 +1302,13 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list, ...@@ -1302,13 +1302,13 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list,
pathnode->path.joinid = ((RestrictInfo *) lfirst(clausegroup))->restrictinfojoinid; pathnode->path.joinid = ((RestrictInfo *) lfirst(clausegroup))->restrictinfojoinid;
pathnode->path.path_cost = cost_index((Oid) lfirsti(index->relids), pathnode->path.path_cost = cost_index((Oid) lfirsti(index->relids),
(int) temp_pages, (int) temp_pages,
temp_selec, temp_selec,
rel->pages, rel->pages,
rel->tuples, rel->tuples,
index->pages, index->pages,
index->tuples, index->tuples,
true); true);
/* /*
* copy restrictinfo list into path for expensive function * copy restrictinfo list into path for expensive function
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.26 1999/02/15 02:04:57 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.27 1999/02/15 03:22:05 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -78,6 +78,7 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels) ...@@ -78,6 +78,7 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels)
Path *bestinnerjoin; Path *bestinnerjoin;
List *pathlist = NIL; List *pathlist = NIL;
/* flatten out relids later in this function */
innerrelids = lsecond(joinrel->relids); innerrelids = lsecond(joinrel->relids);
outerrelids = lfirst(joinrel->relids); outerrelids = lfirst(joinrel->relids);
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.18 1999/02/13 23:16:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.19 1999/02/15 03:22:06 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,7 +47,6 @@ group_clauses_by_order(List *restrictinfo_list, ...@@ -47,7 +47,6 @@ group_clauses_by_order(List *restrictinfo_list,
if (merge_ordering) if (merge_ordering)
{ {
/* /*
* Create a new mergeinfo node and add it to 'mergeinfo_list' * Create a new mergeinfo node and add it to 'mergeinfo_list'
* if one does not yet exist for this merge ordering. * if one does not yet exist for this merge ordering.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.32 1999/02/14 04:56:47 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.33 1999/02/15 03:22:06 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -106,7 +106,7 @@ rels_set_cheapest(List *rel_list) ...@@ -106,7 +106,7 @@ rels_set_cheapest(List *rel_list)
} }
} }
#ifdef NOT_USED
/* /*
* merge_joinrels * merge_joinrels
* Given two lists of rel nodes that are already * Given two lists of rel nodes that are already
...@@ -133,7 +133,7 @@ merge_joinrels(List *rel_list1, List *rel_list2) ...@@ -133,7 +133,7 @@ merge_joinrels(List *rel_list1, List *rel_list2)
/* /*
* prune_oldrels * prune_oldrels
* If all the joininfo's in a rel node are inactive, * If all the joininfo's in a rel node are bushy_inactive,
* that means that this node has been joined into * that means that this node has been joined into
* other nodes in all possible ways, therefore * other nodes in all possible ways, therefore
* this node can be discarded. If not, it will cause * this node can be discarded. If not, it will cause
...@@ -165,7 +165,7 @@ prune_oldrels(List *old_rels) ...@@ -165,7 +165,7 @@ prune_oldrels(List *old_rels)
{ {
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo); JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
if (!joininfo->inactive) if (!joininfo->bushy_inactive)
{ {
temp_list = lcons(rel, temp_list); temp_list = lcons(rel, temp_list);
break; break;
...@@ -175,3 +175,5 @@ prune_oldrels(List *old_rels) ...@@ -175,3 +175,5 @@ prune_oldrels(List *old_rels)
} }
return temp_list; return temp_list;
} }
#endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.25 1999/02/15 01:06:58 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.26 1999/02/15 03:22:11 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -339,14 +339,14 @@ set_joininfo_mergeable_hashable(List *rel_list) ...@@ -339,14 +339,14 @@ set_joininfo_mergeable_hashable(List *rel_list)
if (_enable_mergejoin_) if (_enable_mergejoin_)
sortop = mergejoinop(clause); sortop = mergejoinop(clause);
if (_enable_hashjoin_)
hashop = hashjoinop(clause);
if (sortop) if (sortop)
{ {
restrictinfo->mergejoinorder = sortop; restrictinfo->mergejoinorder = sortop;
joininfo->mergejoinable = true; joininfo->mergejoinable = true;
} }
if (_enable_hashjoin_)
hashop = hashjoinop(clause);
if (hashop) if (hashop)
{ {
restrictinfo->hashjoinoperator = hashop; restrictinfo->hashjoinoperator = hashop;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.32 1999/02/14 04:56:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.33 1999/02/15 03:22:12 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -215,7 +215,6 @@ query_planner(Query *root, ...@@ -215,7 +215,6 @@ query_planner(Query *root,
} }
#ifdef NOT_USED #ifdef NOT_USED
/* /*
* Destructively modify the query plan's targetlist to add fjoin lists * Destructively modify the query plan's targetlist to add fjoin lists
* to flatten functions that return sets of base types * to flatten functions that return sets of base types
...@@ -243,7 +242,6 @@ subplanner(Query *root, ...@@ -243,7 +242,6 @@ subplanner(Query *root,
List *qual) List *qual)
{ {
RelOptInfo *final_rel; RelOptInfo *final_rel;
List *final_rel_list;
/* /*
* Initialize the targetlist and qualification, adding entries to * Initialize the targetlist and qualification, adding entries to
...@@ -259,12 +257,7 @@ subplanner(Query *root, ...@@ -259,12 +257,7 @@ subplanner(Query *root,
set_joininfo_mergeable_hashable(root->base_rel_list); set_joininfo_mergeable_hashable(root->base_rel_list);
final_rel_list = find_paths(root, root->base_rel_list); final_rel = make_one_rel(root, root->base_rel_list);
if (final_rel_list)
final_rel = (RelOptInfo *) lfirst(final_rel_list);
else
final_rel = (RelOptInfo *) NIL;
#if 0 /* fix xfunc */ #if 0 /* fix xfunc */
...@@ -297,7 +290,7 @@ subplanner(Query *root, ...@@ -297,7 +290,7 @@ subplanner(Query *root,
return create_plan((Path *) final_rel->cheapestpath); return create_plan((Path *) final_rel->cheapestpath);
else else
{ {
elog(NOTICE, "final relation is nil"); elog(NOTICE, "final relation is null");
return create_plan((Path *) NULL); return create_plan((Path *) NULL);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.15 1999/02/13 23:16:45 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.16 1999/02/15 03:22:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -74,7 +74,7 @@ find_joininfo_node(RelOptInfo *this_rel, List *join_relids) ...@@ -74,7 +74,7 @@ find_joininfo_node(RelOptInfo *this_rel, List *join_relids)
joininfo->jinfo_restrictinfo = NIL; joininfo->jinfo_restrictinfo = NIL;
joininfo->mergejoinable = false; joininfo->mergejoinable = false;
joininfo->hashjoinable = false; joininfo->hashjoinable = false;
joininfo->inactive = false; joininfo->bushy_inactive = false;
this_rel->joininfo = lcons(joininfo, this_rel->joininfo); this_rel->joininfo = lcons(joininfo, this_rel->joininfo);
} }
return joininfo; return joininfo;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.35 1999/02/13 23:16:46 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.36 1999/02/15 03:22:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -381,15 +381,15 @@ create_index_path(Query *root, ...@@ -381,15 +381,15 @@ create_index_path(Query *root,
/* is the statement above really true? what about IndexScan as the /* is the statement above really true? what about IndexScan as the
inner of a join? */ inner of a join? */
pathnode->path.path_cost = cost_index(lfirsti(index->relids), pathnode->path.path_cost = cost_index(lfirsti(index->relids),
index->pages, index->pages,
1.0, 1.0,
rel->pages, rel->pages,
rel->tuples, rel->tuples,
index->pages, index->pages,
index->tuples, index->tuples,
false); false);
/* add in expensive functions cost! -- JMH, 7/7/92 */
#if 0 #if 0
/* add in expensive functions cost! -- JMH, 7/7/92 */
if (XfuncMode != XFUNC_OFF) if (XfuncMode != XFUNC_OFF)
{ {
pathnode->path_cost = (pathnode->path_cost + pathnode->path_cost = (pathnode->path_cost +
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.13 1999/02/13 23:16:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.14 1999/02/15 03:22:17 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -64,14 +64,12 @@ get_base_rel(Query *root, int relid) ...@@ -64,14 +64,12 @@ get_base_rel(Query *root, int relid)
*/ */
if (relid < 0) if (relid < 0)
{ {
/* /*
* If the relation is a materialized relation, assume * If the relation is a materialized relation, assume
* constants for sizes. * constants for sizes.
*/ */
rel->pages = _NONAME_RELATION_PAGES_; rel->pages = _NONAME_RELATION_PAGES_;
rel->tuples = _NONAME_RELATION_TUPLES_; rel->tuples = _NONAME_RELATION_TUPLES_;
} }
else else
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.99 1999/02/13 23:18:45 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.100 1999/02/15 03:22:21 momjian Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -173,8 +173,10 @@ int UseNewLine = 0; /* Use EOF as query delimiters */ ...@@ -173,8 +173,10 @@ int UseNewLine = 0; /* Use EOF as query delimiters */
* plans * plans
* ---------------- * ----------------
*/ */
#ifdef NOT_USED
int BushyPlanFlag = 0; /* default to false -- consider only int BushyPlanFlag = 0; /* default to false -- consider only
* left-deep trees */ * left-deep trees */
#endif
/* /*
** Flags for expensive function optimization -- JMH 3/9/92 ** Flags for expensive function optimization -- JMH 3/9/92
...@@ -1041,6 +1043,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) ...@@ -1041,6 +1043,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
#endif #endif
break; break;
#ifdef NOT_USED
case 'b': case 'b':
/* ---------------- /* ----------------
* set BushyPlanFlag to true. * set BushyPlanFlag to true.
...@@ -1048,6 +1051,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) ...@@ -1048,6 +1051,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
*/ */
BushyPlanFlag = 1; BushyPlanFlag = 1;
break; break;
#endif
case 'B': case 'B':
/* ---------------- /* ----------------
...@@ -1538,7 +1542,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) ...@@ -1538,7 +1542,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster) if (!IsUnderPostmaster)
{ {
puts("\nPOSTGRES backend interactive interface "); puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.99 $ $Date: 1999/02/13 23:18:45 $\n"); puts("$Revision: 1.100 $ $Date: 1999/02/15 03:22:21 $\n");
} }
/* ---------------- /* ----------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: relation.h,v 1.23 1999/02/13 23:21:42 momjian Exp $ * $Id: relation.h,v 1.24 1999/02/15 03:22:23 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -250,7 +250,7 @@ typedef struct JoinInfo ...@@ -250,7 +250,7 @@ typedef struct JoinInfo
List *jinfo_restrictinfo; List *jinfo_restrictinfo;
bool mergejoinable; bool mergejoinable;
bool hashjoinable; bool hashjoinable;
bool inactive; bool bushy_inactive;
} JoinInfo; } JoinInfo;
typedef struct Iter typedef struct Iter
......
/*-------------------------------------------------------------------------
*
* geqo_paths.h
* prototypes for various subroutines in geqo_path.c
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: geqo_paths.h,v 1.9 1999/02/13 23:21:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* contributed by:
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
* Martin Utesch * Institute of Automatic Control *
= = University of Mining and Technology =
* utesch@aut.tu-freiberg.de * Freiberg, Germany *
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
*/
#ifndef GEQO_PATHS_H
#define GEQO_PATHS_H
extern List *geqo_prune_rels(List *rel_list);
extern void geqo_set_cheapest(RelOptInfo *rel);
#endif /* GEQO_PATHS_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: internal.h,v 1.14 1999/02/13 23:21:49 momjian Exp $ * $Id: internal.h,v 1.15 1999/02/15 03:22:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -80,7 +80,9 @@ ...@@ -80,7 +80,9 @@
#define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE) #define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE)
#define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0)) #define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0))
#ifdef NOT_USED
extern int BushyPlanFlag; extern int BushyPlanFlag;
#endif
/* #define deactivate_joininfo(joininfo) joininfo->inactive=true*/ /* #define deactivate_joininfo(joininfo) joininfo->inactive=true*/
/*#define joininfo_inactive(joininfo) joininfo->inactive */ /*#define joininfo_inactive(joininfo) joininfo->inactive */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: paths.h,v 1.16 1999/02/14 04:56:55 momjian Exp $ * $Id: paths.h,v 1.17 1999/02/15 03:22:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
/* /*
* allpaths.h * allpaths.h
*/ */
extern List *find_paths(Query *root, List *rels); extern RelOptInfo *make_one_rel(Query *root, List *rels);
/* /*
* indxpath.h * indxpath.h
...@@ -77,16 +77,19 @@ extern MergeInfo *match_order_mergeinfo(PathOrder *ordering, ...@@ -77,16 +77,19 @@ extern MergeInfo *match_order_mergeinfo(PathOrder *ordering,
* joinrels.h * joinrels.h
* routines to determine which relations to join * routines to determine which relations to join
*/ */
extern List *make_new_rels_by_joins(Query *root, List *outer_rels); extern List *make_rels_by_joins(Query *root, List *outer_rels);
extern void add_new_joininfos(Query *root, List *joinrels, List *outerrels); extern void add_new_joininfos(Query *root, List *joinrels, List *outerrels);
extern List *final_join_rels(List *join_rel_list); extern List *make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
List *joininfo_list, List *only_relids);
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);
/* /*
* prototypes for path/prune.c * prototypes for path/prune.c
*/ */
extern void merge_rels_with_same_relids(List *rel_list); extern void merge_rels_with_same_relids(List *rel_list);
extern void rels_set_cheapest(List *rel_list); extern void rels_set_cheapest(List *rel_list);
extern List *merge_joinrels(List *rel_list1, List *rel_list2);
extern List *prune_oldrels(List *old_rels);
#endif /* PATHS_H */ #endif /* PATHS_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: proc.h,v 1.17 1999/02/13 23:22:09 momjian Exp $ * $Id: proc.h,v 1.18 1999/02/15 03:22:37 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -75,8 +75,15 @@ typedef struct procglobal ...@@ -75,8 +75,15 @@ typedef struct procglobal
extern PROC *MyProc; extern PROC *MyProc;
#define PROC_INCR_SLOCK(lock) if (MyProc) ((MyProc->sLocks[(lock)])++) #define PROC_INCR_SLOCK(lock) \
#define PROC_DECR_SLOCK(lock) if (MyProc) ((MyProc->sLocks[(lock)])--) do { \
if (MyProc) (MyProc->sLocks[(lock)])++; \
} while (0)
#define PROC_DECR_SLOCK(lock) \
do { \
if (MyProc) (MyProc->sLocks[(lock)])--; \
} while (0)
/* /*
* flags explaining why process woke up * flags explaining why process woke up
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment