otherrels is now unjoined_rels

This commit is contained in:
Bruce Momjian 1999-02-15 05:21:12 +00:00
parent 82682ff31f
commit c5449d5354
12 changed files with 78 additions and 84 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.71 1999/02/15 03:21:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.72 1999/02/15 05:21:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -1428,7 +1428,7 @@ _copyJoinInfo(JoinInfo *from)
* copy remainder of node
* ----------------
*/
newnode->otherrels = listCopy(from->otherrels);
newnode->unjoined_rels = listCopy(from->unjoined_rels);
Node_Copy(from, newnode, jinfo_restrictinfo);
newnode->mergejoinable = from->mergejoinable;

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.33 1999/02/15 03:21:59 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.34 1999/02/15 05:21:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -526,7 +526,7 @@ _equalJoinInfo(JoinInfo *a, JoinInfo *b)
{
Assert(IsA(a, JoinInfo));
Assert(IsA(b, JoinInfo));
if (!equal(a->otherrels, b->otherrels))
if (!equal(a->unjoined_rels, b->unjoined_rels))
return false;
if (!equal(a->jinfo_restrictinfo, b->jinfo_restrictinfo))
return false;

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.11 1999/02/15 03:21:59 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.12 1999/02/15 05:21:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -1024,7 +1024,7 @@ _freeJoinInfo(JoinInfo *node)
* free remainder of node
* ----------------
*/
freeList(node->otherrels);
freeList(node->unjoined_rels);
freeObject(node->jinfo_restrictinfo);
pfree(node);

View File

@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: outfuncs.c,v 1.73 1999/02/15 03:21:59 momjian Exp $
* $Id: outfuncs.c,v 1.74 1999/02/15 05:21:02 momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@ -1198,8 +1198,8 @@ _outHashInfo(StringInfo str, HashInfo *node)
static void
_outJoinInfo(StringInfo str, JoinInfo *node)
{
appendStringInfo(str, " JINFO :otherrels ");
_outIntList(str, node->otherrels);
appendStringInfo(str, " JINFO :unjoined_rels ");
_outIntList(str, node->unjoined_rels);
appendStringInfo(str, " :jinfo_restrictinfo ");
_outNode(str, node->jinfo_restrictinfo);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.57 1999/02/13 23:16:02 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.58 1999/02/15 05:21:03 momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
@ -1982,8 +1982,8 @@ _readJoinInfo()
local_node = makeNode(JoinInfo);
token = lsptok(NULL, &length); /* get :otherrels */
local_node->otherrels = toIntList(nodeRead(true)); /* now read it */
token = lsptok(NULL, &length); /* get :unjoined_rels */
local_node->unjoined_rels = toIntList(nodeRead(true)); /* now read it */
token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */
local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.36 1999/02/15 03:59:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.37 1999/02/15 05:21:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -43,8 +43,9 @@ bool _use_geqo_ = false;
int32 _use_geqo_rels_ = GEQO_RELS;
static void find_base_rel_paths(Query *root, List *rels);
static RelOptInfo *make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed);
static void set_base_rel_pathlist(Query *root, List *rels);
static RelOptInfo *make_one_rel_by_joins(Query *root, List *rels,
int levels_needed);
#ifdef OPTIMIZER_DEBUG
static void debug_print_rel(Query *root, RelOptInfo *rel);
@ -71,7 +72,7 @@ make_one_rel(Query *root, List *rels)
if (levels_needed <= 0)
return NULL;
find_base_rel_paths(root, rels);
set_base_rel_pathlist(root, rels);
if (levels_needed <= 1)
{
@ -83,7 +84,7 @@ make_one_rel(Query *root, List *rels)
else
{
/*
* this means that joins or sorts are required. set selectivities
* This means that joins or sorts are required. set selectivities
* of clauses that have not been set by an index.
*/
set_rest_relselec(root, rels);
@ -93,7 +94,7 @@ make_one_rel(Query *root, List *rels)
}
/*
* find_base_rel_paths
* set_base_rel_pathlist
* Finds all paths available for scanning each relation entry in
* 'rels'. Sequential scan and any available indices are considered
* if possible(indices are not considered for lower nesting levels).
@ -102,7 +103,7 @@ make_one_rel(Query *root, List *rels)
* MODIFIES: rels
*/
static void
find_base_rel_paths(Query *root, List *rels)
set_base_rel_pathlist(Query *root, List *rels)
{
List *temp;
@ -150,7 +151,7 @@ find_base_rel_paths(Query *root, List *rels)
* Find all possible joinpaths(bushy trees) for a query by systematically
* finding ways to join relations(both original and derived) together.
*
* 'outer_rels' is the current list of relations for which join paths
* 'rels' is the current list of relations for which join paths
* are to be found, i.e., the current list of relations that
* have already been derived.
* 'levels_needed' is the number of iterations needed
@ -159,7 +160,7 @@ find_base_rel_paths(Query *root, List *rels)
* the result of joining all the original relations together.
*/
static RelOptInfo *
make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
make_one_rel_by_joins(Query *root, List *rels, int levels_needed)
{
List *x;
List *joined_rels = NIL;
@ -180,11 +181,11 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
{
/*
* Determine all possible pairs of relations to be joined at this
* level. Determine paths for joining these relation pairs and
* level. Determine paths for joining these relation pairs and
* modify 'joined_rels' accordingly, then eliminate redundant join
* relations.
*/
joined_rels = make_rels_by_joins(root, outer_rels);
joined_rels = make_rels_by_joins(root, rels);
update_rels_pathlist_for_joins(root, joined_rels);
@ -211,7 +212,7 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
* involves the join relation to the joininfo list of the
* other relation
*/
add_rel_to_rel_joininfos(root, joined_rels, outer_rels);
add_rel_to_rel_joininfos(root, joined_rels, rels);
}
#endif
@ -236,33 +237,25 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
* prune rels that have been completely incorporated into new
* join rels
*/
outer_rels = del_rels_all_bushy_inactive(outer_rels);
rels = del_rels_all_bushy_inactive(rels);
/*
* merge join rels if then contain the same list of base rels
*/
outer_rels = merge_rels_with_same_relids(joined_rels, outer_rels);
root->join_rel_list = outer_rels;
joined_rels = merge_rels_with_same_relids(joined_rels, rels);
}
else
#endif
root->join_rel_list = joined_rels;
#ifdef NOT_USED
if (!BushyPlanFlag)
#endif
outer_rels = joined_rels;
root->join_rel_list = rels = joined_rels;
}
Assert(length(joined_rels) == 1);
Assert(BushyPlanFlag || length(rels) == 1);
#ifdef NOT_USED
if (BushyPlanFlag)
return final_join_rels(outer_rels);
return get_cheapest_complete_rel(rels);
else
#endif
return lfirst(joined_rels);
return lfirst(rels);
}
/*****************************************************************************

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.47 1999/02/15 03:22:05 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.48 1999/02/15 05:21:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -1208,7 +1208,7 @@ indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index,
{
List *clauses = lfirst(clausegroups);
((RestrictInfo *) lfirst(clauses))->restrictinfojoinid = joininfo->otherrels;
((RestrictInfo *) lfirst(clauses))->restrictinfojoinid = joininfo->unjoined_rels;
}
cg_list = nconc(cg_list, clausegroups);
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.24 1999/02/15 03:59:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.25 1999/02/15 05:21:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -113,17 +113,17 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
if (!joininfo->bushy_inactive)
{
List *other_rels = joininfo->otherrels;
List *unjoined_rels = joininfo->unjoined_rels;
if (other_rels != NIL)
if (unjoined_rels != NIL)
{
if (length(other_rels) == 1 &&
if (length(unjoined_rels) == 1 &&
(only_relids == NIL ||
/* geqo only wants certain relids to make new rels */
same(joininfo->otherrels, only_relids)))
same(joininfo->unjoined_rels, only_relids)))
{
rel = make_join_rel(outer_rel,
get_base_rel(root, lfirsti(other_rels)),
get_base_rel(root, lfirsti(unjoined_rels)),
joininfo);
/* how about right-sided plan ? */
if (_use_right_sided_plans_ &&
@ -132,7 +132,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
if (rel != NULL)
join_list = lappend(join_list, rel);
rel = make_join_rel(get_base_rel(root,
lfirsti(other_rels)),
lfirsti(unjoined_rels)),
outer_rel,
joininfo);
}
@ -141,7 +141,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
else if (BushyPlanFlag)
{
rel = make_join_rel(outer_rel,
get_join_rel(root, other_rels),
get_join_rel(root, unjoined_rels),
joininfo);
}
#endif
@ -328,7 +328,7 @@ static List *
new_joininfo_list(List *joininfo_list, List *join_relids)
{
List *current_joininfo_list = NIL;
List *new_otherrels = NIL;
List *new_unjoined_rels = NIL;
JoinInfo *other_joininfo = (JoinInfo *) NULL;
List *xjoininfo = NIL;
@ -337,16 +337,16 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
List *or;
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
new_otherrels = joininfo->otherrels;
foreach(or, new_otherrels)
new_unjoined_rels = joininfo->unjoined_rels;
foreach(or, new_unjoined_rels)
{
if (intMember(lfirsti(or), join_relids))
new_otherrels = lremove((void *) lfirst(or), new_otherrels);
new_unjoined_rels = lremove((void *) lfirst(or), new_unjoined_rels);
}
joininfo->otherrels = new_otherrels;
if (new_otherrels != NIL)
joininfo->unjoined_rels = new_unjoined_rels;
if (new_unjoined_rels != NIL)
{
other_joininfo = joininfo_member(new_otherrels,
other_joininfo = joininfo_member(new_unjoined_rels,
current_joininfo_list);
if (other_joininfo)
{
@ -357,7 +357,7 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
{
other_joininfo = makeNode(JoinInfo);
other_joininfo->otherrels = joininfo->otherrels;
other_joininfo->unjoined_rels = joininfo->unjoined_rels;
other_joininfo->jinfo_restrictinfo = joininfo->jinfo_restrictinfo;
other_joininfo->mergejoinable = joininfo->mergejoinable;
other_joininfo->hashjoinable = joininfo->hashjoinable;
@ -410,12 +410,12 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
foreach(xjoininfo, joinrel->joininfo)
{
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
List *other_rels = joininfo->otherrels;
List *unjoined_rels = joininfo->unjoined_rels;
List *restrict_info = joininfo->jinfo_restrictinfo;
bool mergejoinable = joininfo->mergejoinable;
bool hashjoinable = joininfo->hashjoinable;
foreach(xrelid, other_rels)
foreach(xrelid, unjoined_rels)
{
Relid relid = (Relid) lfirst(xrelid);
RelOptInfo *rel = get_join_rel(root, relid);
@ -423,7 +423,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
List *xsuper_rel = NIL;
JoinInfo *new_joininfo = makeNode(JoinInfo);
new_joininfo->otherrels = joinrel->relids;
new_joininfo->unjoined_rels = joinrel->relids;
new_joininfo->jinfo_restrictinfo = restrict_info;
new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable;
@ -449,7 +449,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
{
JoinInfo *new_joininfo = makeNode(JoinInfo);
new_joininfo->otherrels = new_relids;
new_joininfo->unjoined_rels = new_relids;
new_joininfo->jinfo_restrictinfo = restrict_info;
new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable;
@ -473,7 +473,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
#ifdef NOT_USED
/*
* final_join_rels
* get_cheapest_complete_rel
* Find the join relation that includes all the original
* relations, i.e. the final join result.
*
@ -482,14 +482,14 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
* Returns the list of final join relations.
*/
RelOptInfo *
final_join_rels(List *join_rel_list)
get_cheapest_complete_rel(List *join_rel_list)
{
List *xrel = NIL;
RelOptInfo *final_rel = NULL;
/*
* find the relations that has no further joins, i.e., its joininfos
* all have otherrels nil.
* all have unjoined_rels nil.
*/
foreach(xrel, join_rel_list)
{
@ -501,7 +501,7 @@ final_join_rels(List *join_rel_list)
{
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
if (joininfo->otherrels != NIL)
if (joininfo->unjoined_rels != NIL)
{
final = false;
break;

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.34 1999/02/15 03:59:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.35 1999/02/15 05:21:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -24,7 +24,7 @@
#include "utils/elog.h"
static List *merge_rel_with_same_relids(RelOptInfo *rel, List *other_rels);
static List *merge_rel_with_same_relids(RelOptInfo *rel, List *unjoined_rels);
/*
* merge_rels_with_same_relids
@ -48,8 +48,8 @@ merge_rels_with_same_relids(List *rel_list)
}
/*
* merge_rel_with_same_relids
* Prunes those relations from 'other_rels' that are redundant with
* merge_rel_with_same_relids
* Prunes those relations from 'unjoined_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'.
@ -59,25 +59,25 @@ merge_rels_with_same_relids(List *rel_list)
*
*/
static List *
merge_rel_with_same_relids(RelOptInfo *rel, List *other_rels)
merge_rel_with_same_relids(RelOptInfo *rel, List *unjoined_rels)
{
List *i = NIL;
List *result = NIL;
foreach(i, other_rels)
foreach(i, unjoined_rels)
{
RelOptInfo *other_rel = (RelOptInfo *) lfirst(i);
RelOptInfo *unjoined_rel = (RelOptInfo *) lfirst(i);
if (same(rel->relids, other_rel->relids))
if (same(rel->relids, unjoined_rel->relids))
/*
* This are on the same relations,
* so get the best of their pathlists.
*/
rel->pathlist = add_pathlist(rel,
rel->pathlist,
other_rel->pathlist);
unjoined_rel->pathlist);
else
result = lappend(result, other_rel);
result = lappend(result, unjoined_rel);
}
return result;
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.26 1999/02/15 03:22:11 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.27 1999/02/15 05:21:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -246,18 +246,19 @@ add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, List *join_relids
foreach(join_relid, join_relids)
{
JoinInfo *joininfo;
List *other_rels = NIL;
List *unjoined_rels = NIL;
List *rel;
foreach(rel, join_relids)
{
if (lfirsti(rel) != lfirsti(join_relid))
other_rels = lappendi(other_rels, lfirsti(rel));
unjoined_rels = lappendi(unjoined_rels, lfirsti(rel));
}
joininfo = find_joininfo_node(get_base_rel(root, lfirsti(join_relid)),
other_rels);
joininfo->jinfo_restrictinfo = lcons(copyObject((void *) restrictinfo), joininfo->jinfo_restrictinfo);
unjoined_rels);
joininfo->jinfo_restrictinfo = lcons(copyObject((void *) restrictinfo),
joininfo->jinfo_restrictinfo);
}
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.16 1999/02/15 03:22:16 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.17 1999/02/15 05:21:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -44,7 +44,7 @@ joininfo_member(List *join_relids, List *joininfo_list)
foreach(i, joininfo_list)
{
other_rels = lfirst(i);
if (same(join_relids, ((JoinInfo *) other_rels)->otherrels))
if (same(join_relids, ((JoinInfo *) other_rels)->unjoined_rels))
return (JoinInfo *) other_rels;
}
return (JoinInfo *) NULL;
@ -70,7 +70,7 @@ find_joininfo_node(RelOptInfo *this_rel, List *join_relids)
if (joininfo == NULL)
{
joininfo = makeNode(JoinInfo);
joininfo->otherrels = join_relids;
joininfo->unjoined_rels = join_relids;
joininfo->jinfo_restrictinfo = NIL;
joininfo->mergejoinable = false;
joininfo->hashjoinable = false;

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: relation.h,v 1.24 1999/02/15 03:22:23 momjian Exp $
* $Id: relation.h,v 1.25 1999/02/15 05:21:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -246,7 +246,7 @@ typedef struct MergeInfo
typedef struct JoinInfo
{
NodeTag type;
List *otherrels;
List *unjoined_rels;
List *jinfo_restrictinfo;
bool mergejoinable;
bool hashjoinable;