mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
optimizer cleanup.
This commit is contained in:
parent
808a6df065
commit
d8b482be7c
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.33 1999/02/14 05:14:08 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.34 1999/02/14 05:27:11 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -162,7 +162,7 @@ static List *
|
|||||||
find_join_paths(Query *root, List *outer_rels, int levels_needed)
|
find_join_paths(Query *root, List *outer_rels, int levels_needed)
|
||||||
{
|
{
|
||||||
List *x;
|
List *x;
|
||||||
List *new_rels = NIL;
|
List *joined_rels = NIL;
|
||||||
RelOptInfo *rel;
|
RelOptInfo *rel;
|
||||||
|
|
||||||
/*******************************************
|
/*******************************************
|
||||||
@ -181,14 +181,14 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
|
|||||||
/*
|
/*
|
||||||
* Determine all possible pairs of relations to be joined at this
|
* 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 'new_rels' accordingly, then eliminate redundant join
|
* modify 'joined_rels' accordingly, then eliminate redundant join
|
||||||
* relations.
|
* relations.
|
||||||
*/
|
*/
|
||||||
new_rels = make_new_rels_by_joins(root, outer_rels);
|
joined_rels = make_new_rels_by_joins(root, outer_rels);
|
||||||
|
|
||||||
update_rels_pathlist_for_joins(root, new_rels);
|
update_rels_pathlist_for_joins(root, joined_rels);
|
||||||
|
|
||||||
merge_rels_with_same_relids(new_rels);
|
merge_rels_with_same_relids(joined_rels);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/*
|
/*
|
||||||
@ -196,11 +196,11 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
|
|||||||
* rel, * consider doing pullup -- JMH
|
* rel, * consider doing pullup -- JMH
|
||||||
*/
|
*/
|
||||||
if (XfuncMode != XFUNC_NOPULL && XfuncMode != XFUNC_OFF)
|
if (XfuncMode != XFUNC_NOPULL && XfuncMode != XFUNC_OFF)
|
||||||
foreach(x, new_rels)
|
foreach(x, joined_rels)
|
||||||
xfunc_trypullup((RelOptInfo *) lfirst(x));
|
xfunc_trypullup((RelOptInfo *) lfirst(x));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rels_set_cheapest(new_rels);
|
rels_set_cheapest(joined_rels);
|
||||||
|
|
||||||
if (BushyPlanFlag)
|
if (BushyPlanFlag)
|
||||||
{
|
{
|
||||||
@ -211,10 +211,10 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
|
|||||||
* involves the join relation to the joininfo list of the
|
* involves the join relation to the joininfo list of the
|
||||||
* other relation
|
* other relation
|
||||||
*/
|
*/
|
||||||
add_new_joininfos(root, new_rels, outer_rels);
|
add_new_joininfos(root, joined_rels, outer_rels);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(x, new_rels)
|
foreach(x, joined_rels)
|
||||||
{
|
{
|
||||||
rel = (RelOptInfo *) lfirst(x);
|
rel = (RelOptInfo *) lfirst(x);
|
||||||
|
|
||||||
@ -239,20 +239,20 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
|
|||||||
/*
|
/*
|
||||||
* merge join rels if then contain the same list of base rels
|
* merge join rels if then contain the same list of base rels
|
||||||
*/
|
*/
|
||||||
outer_rels = merge_joinrels(new_rels, outer_rels);
|
outer_rels = merge_joinrels(joined_rels, outer_rels);
|
||||||
root->join_rel_list = outer_rels;
|
root->join_rel_list = outer_rels;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
root->join_rel_list = new_rels;
|
root->join_rel_list = joined_rels;
|
||||||
|
|
||||||
if (!BushyPlanFlag)
|
if (!BushyPlanFlag)
|
||||||
outer_rels = new_rels;
|
outer_rels = joined_rels;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BushyPlanFlag)
|
if (BushyPlanFlag)
|
||||||
return final_join_rels(outer_rels);
|
return final_join_rels(outer_rels);
|
||||||
else
|
else
|
||||||
return new_rels;
|
return joined_rels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.24 1999/02/14 04:56:46 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.25 1999/02/14 05:27:12 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -66,8 +66,6 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels)
|
|||||||
{
|
{
|
||||||
List *mergeinfo_list = NIL;
|
List *mergeinfo_list = NIL;
|
||||||
List *hashinfo_list = NIL;
|
List *hashinfo_list = NIL;
|
||||||
List *temp_list = NIL;
|
|
||||||
List *path = NIL;
|
|
||||||
List *j;
|
List *j;
|
||||||
|
|
||||||
foreach(j, joinrels)
|
foreach(j, joinrels)
|
||||||
@ -144,37 +142,11 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels)
|
|||||||
* 4. Consider paths where both outer and inner relations must be
|
* 4. Consider paths where both outer and inner relations must be
|
||||||
* hashed before being joined.
|
* hashed before being joined.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pathlist = add_pathlist(joinrel, pathlist,
|
pathlist = add_pathlist(joinrel, pathlist,
|
||||||
hash_inner_and_outer(joinrel, outerrel,
|
hash_inner_and_outer(joinrel, outerrel,
|
||||||
innerrel, hashinfo_list));
|
innerrel, hashinfo_list));
|
||||||
|
|
||||||
joinrel->pathlist = pathlist;
|
joinrel->pathlist = pathlist;
|
||||||
|
|
||||||
/*
|
|
||||||
* 'OuterJoinCost is only valid when calling
|
|
||||||
* (match_unsorted_inner) with the same arguments as the previous
|
|
||||||
* invokation of (match_unsorted_outer), so clear the field before
|
|
||||||
* going on.
|
|
||||||
*/
|
|
||||||
temp_list = innerrel->pathlist;
|
|
||||||
foreach(path, temp_list)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* XXX
|
|
||||||
*
|
|
||||||
* This gross hack is to get around an apparent optimizer bug on
|
|
||||||
* Sparc (or maybe it is a bug of ours?) that causes really
|
|
||||||
* wierd behavior.
|
|
||||||
*/
|
|
||||||
if (IsA_JoinPath(path))
|
|
||||||
((Path *) lfirst(path))->outerjoincost = (Cost) 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* do it iff it is a join path, which is not always true, esp
|
|
||||||
* since the base level
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user