1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-11 00:12:06 +03:00

MergeSort was sometimes called mergejoin and was confusing. Now

it is now only mergejoin.
This commit is contained in:
Bruce Momjian
1998-08-04 16:44:31 +00:00
parent 7db9ea5c1e
commit d9be0ff432
23 changed files with 117 additions and 116 deletions

View File

@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: geqo_eval.c,v 1.20 1998/07/18 04:22:27 momjian Exp $
* $Id: geqo_eval.c,v 1.21 1998/08/04 16:44:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -422,8 +422,8 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
joininfo->otherrels;
other_joininfo->jinfoclauseinfo =
joininfo->jinfoclauseinfo;
other_joininfo->mergesortable =
joininfo->mergesortable;
other_joininfo->mergejoinable =
joininfo->mergejoinable;
other_joininfo->hashjoinable =
joininfo->hashjoinable;
other_joininfo->inactive = false;
@@ -509,7 +509,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
JInfo *joininfo = (JInfo *) lfirst(xjoininfo);
List *other_rels = joininfo->otherrels;
List *clause_info = joininfo->jinfoclauseinfo;
bool mergesortable = joininfo->mergesortable;
bool mergejoinable = joininfo->mergejoinable;
bool hashjoinable = joininfo->hashjoinable;
foreach(xrelid, other_rels)
@@ -541,7 +541,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
new_joininfo->otherrels = joinrel->relids;
new_joininfo->jinfoclauseinfo = clause_info;
new_joininfo->mergesortable = mergesortable;
new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable;
new_joininfo->inactive = false;
rel->joininfo =
@@ -570,7 +570,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
new_joininfo->otherrels = new_relids;
new_joininfo->jinfoclauseinfo = clause_info;
new_joininfo->mergesortable = mergesortable;
new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable;
new_joininfo->inactive = false;
joinrel->joininfo =

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.22 1998/07/18 04:22:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.23 1998/08/04 16:44:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,7 +47,7 @@ bool _enable_indexscan_ = true;
bool _enable_sort_ = true;
bool _enable_hash_ = true;
bool _enable_nestloop_ = true;
bool _enable_mergesort_ = true;
bool _enable_mergejoin_ = true;
bool _enable_hashjoin_ = true;
Cost _cpu_page_wight_ = _CPU_PAGE_WEIGHT_;
@@ -259,7 +259,7 @@ cost_nestloop(Cost outercost,
}
/*
* cost_mergesort--
* cost_mergejoin--
* 'outercost' and 'innercost' are the (disk+cpu) costs of scanning the
* outer and inner relations
* 'outersortkeys' and 'innersortkeys' are lists of the keys to be used
@@ -273,7 +273,7 @@ cost_nestloop(Cost outercost,
*
*/
Cost
cost_mergesort(Cost outercost,
cost_mergejoin(Cost outercost,
Cost innercost,
List *outersortkeys,
List *innersortkeys,
@@ -284,7 +284,7 @@ cost_mergesort(Cost outercost,
{
Cost temp = 0;
if (!_enable_mergesort_)
if (!_enable_mergejoin_)
temp += _disable_cost_;
temp += outercost;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.24 1998/08/04 00:42:08 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.25 1998/08/04 16:44:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1251,7 +1251,7 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list,
*
* 'rel' is the relation for which 'index' is defined
* 'clausegroup-list' is the list of clause groups (lists of clauseinfo
* nodes) grouped by mergesortorder
* nodes) grouped by mergejoinorder
* 'join' is a flag indicating whether or not the clauses are join
* clauses
*
@@ -1284,7 +1284,7 @@ create_index_paths(Query *root,
clauseinfo = (CInfo *) lfirst(j);
if (!(join_clause_p((Node *) clauseinfo->clause) &&
equal_path_merge_ordering(index->ordering,
clauseinfo->mergesortorder)))
clauseinfo->mergejoinorder)))
temp = false;
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.7 1998/07/18 04:22:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.8 1998/08/04 16:44:07 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,7 +27,7 @@
#include "optimizer/pathnode.h"
#include "optimizer/keys.h"
#include "optimizer/cost.h" /* for _enable_{hashjoin,
* _enable_mergesort} */
* _enable_mergejoin} */
static Path *best_innerjoin(List *join_paths, List *outer_relid);
static List *
@@ -98,7 +98,7 @@ find_all_join_paths(Query *root, List *joinrels)
bestinnerjoin = best_innerjoin(innerrel->innerjoin,
outerrel->relids);
if (_enable_mergesort_)
if (_enable_mergejoin_)
{
mergeinfo_list =
group_clauses_by_order(joinrel->clauseinfo,
@@ -116,7 +116,7 @@ find_all_join_paths(Query *root, List *joinrels)
joinrel->relids = intAppend(outerrelids, innerrelids);
/*
* 1. Consider mergesort paths where both relations must be
* 1. Consider mergejoin paths where both relations must be
* explicitly sorted.
*/
pathlist = sort_inner_and_outer(joinrel, outerrel,
@@ -125,7 +125,7 @@ find_all_join_paths(Query *root, List *joinrels)
/*
* 2. Consider paths where the outer relation need not be
* explicitly sorted. This may include either nestloops and
* mergesorts where the outer path is already ordered.
* mergejoins where the outer path is already ordered.
*/
pathlist =
add_pathlist(joinrel, pathlist,
@@ -139,7 +139,7 @@ find_all_join_paths(Query *root, List *joinrels)
/*
* 3. Consider paths where the inner relation need not be
* explicitly sorted. This may include nestloops and mergesorts
* explicitly sorted. This may include nestloops and mergejoins
* the actual nestloop nodes were constructed in
* (match-unsorted-outer).
*/
@@ -226,16 +226,16 @@ best_innerjoin(List *join_paths, List *outer_relids)
/*
* sort-inner-and-outer--
* Create mergesort join paths by explicitly sorting both the outer and
* Create mergejoin join paths by explicitly sorting both the outer and
* inner join relations on each available merge ordering.
*
* 'joinrel' is the join relation
* 'outerrel' is the outer join relation
* 'innerrel' is the inner join relation
* 'mergeinfo-list' is a list of nodes containing info on(mergesortable)
* 'mergeinfo-list' is a list of nodes containing info on(mergejoinable)
* clauses for joining the relations
*
* Returns a list of mergesort paths.
* Returns a list of mergejoin paths.
*/
static List *
sort_inner_and_outer(RelOptInfo *joinrel,
@@ -270,7 +270,7 @@ sort_inner_and_outer(RelOptInfo *joinrel,
xmergeinfo->jmethod.clauses);
temp_node =
create_mergesort_path(joinrel,
create_mergejoin_path(joinrel,
outerrel->size,
innerrel->size,
outerrel->width,
@@ -292,12 +292,12 @@ sort_inner_and_outer(RelOptInfo *joinrel,
* match-unsorted-outer--
* Creates possible join paths for processing a single join relation
* 'joinrel' by employing either iterative substitution or
* mergesorting on each of its possible outer paths(assuming that the
* mergejoining on each of its possible outer paths(assuming that the
* outer relation need not be explicitly sorted).
*
* 1. The inner path is the cheapest available inner path.
* 2. Mergesort wherever possible. Mergesorts are considered if there
* are mergesortable join clauses between the outer and inner join
* 2. Mergejoin wherever possible. Mergejoin are considered if there
* are mergejoinable join clauses between the outer and inner join
* relations such that the outer path is keyed on the variables
* appearing in the clauses. The corresponding inner merge path is
* either a path whose keys match those of the outer path(if such a
@@ -310,7 +310,7 @@ sort_inner_and_outer(RelOptInfo *joinrel,
* 'outerpath-list' is the list of possible outer paths
* 'cheapest-inner' is the cheapest inner path
* 'best-innerjoin' is the best inner index path(if any)
* 'mergeinfo-list' is a list of nodes containing info on mergesortable
* 'mergeinfo-list' is a list of nodes containing info on mergejoinable
* clauses
*
* Returns a list of possible join path nodes.
@@ -424,7 +424,7 @@ match_unsorted_outer(RelOptInfo *joinrel,
mergeinnerpath = cheapest_inner;
temp_node =
lcons(create_mergesort_path(joinrel,
lcons(create_mergejoin_path(joinrel,
outerrel->size,
innerrel->size,
outerrel->width,
@@ -463,7 +463,7 @@ match_unsorted_outer(RelOptInfo *joinrel,
* 'outerrel' is the outer join relation
* 'innerrel' is the inner join relation
* 'innerpath-list' is the list of possible inner join paths
* 'mergeinfo-list' is a list of nodes containing info on mergesortable
* 'mergeinfo-list' is a list of nodes containing info on mergejoinable
* clauses
*
* Returns a list of possible merge paths.
@@ -542,7 +542,7 @@ match_unsorted_inner(RelOptInfo *joinrel,
clauses);
temp_node =
lcons(create_mergesort_path(joinrel,
lcons(create_mergejoin_path(joinrel,
outerrel->size,
innerrel->size,
outerrel->width,

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.11 1998/07/18 04:22:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.12 1998/08/04 16:44:08 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -360,8 +360,8 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
joininfo->otherrels;
other_joininfo->jinfoclauseinfo =
joininfo->jinfoclauseinfo;
other_joininfo->mergesortable =
joininfo->mergesortable;
other_joininfo->mergejoinable =
joininfo->mergejoinable;
other_joininfo->hashjoinable =
joininfo->hashjoinable;
other_joininfo->inactive = false;
@@ -415,7 +415,7 @@ add_new_joininfos(Query *root, List *joinrels, List *outerrels)
JInfo *joininfo = (JInfo *) lfirst(xjoininfo);
List *other_rels = joininfo->otherrels;
List *clause_info = joininfo->jinfoclauseinfo;
bool mergesortable = joininfo->mergesortable;
bool mergejoinable = joininfo->mergejoinable;
bool hashjoinable = joininfo->hashjoinable;
foreach(xrelid, other_rels)
@@ -428,7 +428,7 @@ add_new_joininfos(Query *root, List *joinrels, List *outerrels)
new_joininfo->otherrels = joinrel->relids;
new_joininfo->jinfoclauseinfo = clause_info;
new_joininfo->mergesortable = mergesortable;
new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable;
new_joininfo->inactive = false;
rel->joininfo =
@@ -457,7 +457,7 @@ add_new_joininfos(Query *root, List *joinrels, List *outerrels)
new_joininfo->otherrels = new_relids;
new_joininfo->jinfoclauseinfo = clause_info;
new_joininfo->mergesortable = mergesortable;
new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable;
new_joininfo->inactive = false;
joinrel->joininfo =

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.6 1998/08/04 00:42:09 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.7 1998/08/04 16:44:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,9 +23,9 @@
/*
* group-clauses-by-order--
* If a join clause node in 'clauseinfo-list' is mergesortable, store
* If a join clause node in 'clauseinfo-list' is mergejoinable, store
* it within a mergeinfo node containing other clause nodes with the same
* mergesort ordering.
* mergejoin ordering.
*
* 'clauseinfo-list' is the list of clauseinfo nodes
* 'inner-relid' is the relid of the inner join relation
@@ -43,7 +43,7 @@ group_clauses_by_order(List *clauseinfo_list,
foreach(xclauseinfo, clauseinfo_list)
{
CInfo *clauseinfo = (CInfo *) lfirst(xclauseinfo);
MergeOrder *merge_ordering = clauseinfo->mergesortorder;
MergeOrder *merge_ordering = clauseinfo->mergejoinorder;
if (merge_ordering)
{

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.16 1998/07/18 04:22:34 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.17 1998/08/04 16:44:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1022,7 +1022,7 @@ xfunc_total_path_cost(JoinPath pathnode)
{
MergePath mrgnode = (MergePath) pathnode;
cost += cost_mergesort(get_path_cost((Path) get_outerjoinpath(mrgnode)),
cost += cost_mergejoin(get_path_cost((Path) get_outerjoinpath(mrgnode)),
get_path_cost((Path) get_innerjoinpath(mrgnode)),
get_outersortkeys(mrgnode),
get_innersortkeys(mrgnode),

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.29 1998/07/18 04:22:36 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.30 1998/08/04 16:44:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -79,7 +79,7 @@ make_hashjoin(List *tlist, List *qpqual,
List *hashclauses, Plan *lefttree, Plan *righttree);
static Hash *make_hash(List *tlist, Var *hashkey, Plan *lefttree);
static MergeJoin *
make_mergesort(List *tlist, List *qpqual,
make_mergejoin(List *tlist, List *qpqual,
List *mergeclauses, Oid opcode, Oid *rightorder,
Oid *leftorder, Plan *righttree, Plan *lefttree);
static Material *
@@ -584,7 +584,7 @@ create_mergejoin_node(MergePath *best_path,
inner_node = (Plan *) sorted_inner_node;
}
join_node = make_mergesort(tlist,
join_node = make_mergejoin(tlist,
qpqual,
mergeclauses,
opcode,
@@ -1038,7 +1038,7 @@ make_hash(List *tlist, Var *hashkey, Plan *lefttree)
}
static MergeJoin *
make_mergesort(List *tlist,
make_mergejoin(List *tlist,
List *qpqual,
List *mergeclauses,
Oid opcode,
@@ -1058,7 +1058,7 @@ make_mergesort(List *tlist,
plan->lefttree = lefttree;
plan->righttree = righttree;
node->mergeclauses = mergeclauses;
node->mergesortop = opcode;
node->mergejoinop = opcode;
node->mergerightorder = rightorder;
node->mergeleftorder = leftorder;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.13 1998/07/18 04:22:37 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.14 1998/08/04 16:44:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -41,7 +41,7 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo,
List *join_relids);
static void add_vars_to_rels(Query *root, List *vars, List *join_relids);
static MergeOrder *mergesortop(Expr *clause);
static MergeOrder *mergejoinop(Expr *clause);
static Oid hashjoinop(Expr *clause);
@@ -180,7 +180,7 @@ add_clause_to_rels(Query *root, List *clause)
clauseinfo->notclause = contains_not((Node *) clause);
clauseinfo->selectivity = 0;
clauseinfo->indexids = NIL;
clauseinfo->mergesortorder = (MergeOrder *) NULL;
clauseinfo->mergejoinorder = (MergeOrder *) NULL;
clauseinfo->hashjoinoperator = (Oid) 0;
@@ -324,8 +324,8 @@ add_vars_to_rels(Query *root, List *vars, List *join_relids)
/*
* initialize-join-clause-info--
* Set the MergeSortable or HashJoinable field for every joininfo node
* (within a rel node) and the MergeSortOrder or HashJoinOp field for
* Set the MergeJoinable or HashJoinable field for every joininfo node
* (within a rel node) and the MergeJoinOrder or HashJoinOp field for
* each clauseinfo node(within a joininfo node) for all relations in a
* query.
*
@@ -357,15 +357,15 @@ initialize_join_clause_info(List *rel_list)
MergeOrder *sortop = (MergeOrder *) NULL;
Oid hashop = (Oid) NULL;
if (_enable_mergesort_)
sortop = mergesortop(clause);
if (_enable_mergejoin_)
sortop = mergejoinop(clause);
if (_enable_hashjoin_)
hashop = hashjoinop(clause);
if (sortop)
{
clauseinfo->mergesortorder = sortop;
joininfo->mergesortable = true;
clauseinfo->mergejoinorder = sortop;
joininfo->mergejoinable = true;
}
if (hashop)
{
@@ -379,19 +379,19 @@ initialize_join_clause_info(List *rel_list)
}
/*
* mergesortop--
* Returns the mergesort operator of an operator iff 'clause' is
* mergesortable, i.e., both operands are single vars and the operator is
* a mergesortable operator.
* mergejoinop--
* Returns the mergejoin operator of an operator iff 'clause' is
* mergejoinable, i.e., both operands are single vars and the operator is
* a mergejoinable operator.
*/
static MergeOrder *
mergesortop(Expr *clause)
mergejoinop(Expr *clause)
{
Oid leftOp,
rightOp;
bool sortable;
sortable = op_mergesortable(((Oper *) clause->oper)->opno,
sortable = op_mergejoinable(((Oper *) clause->oper)->opno,
(get_leftop(clause))->vartype,
(get_rightop(clause))->vartype,
&leftOp,

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.8 1998/07/18 04:22:40 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.9 1998/08/04 16:44:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -72,7 +72,7 @@ find_joininfo_node(RelOptInfo *this_rel, List *join_relids)
joininfo = makeNode(JInfo);
joininfo->otherrels = join_relids;
joininfo->jinfoclauseinfo = NIL;
joininfo->mergesortable = false;
joininfo->mergejoinable = false;
joininfo->hashjoinable = false;
joininfo->inactive = false;
this_rel->joininfo = lcons(joininfo, this_rel->joininfo);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.9 1998/07/18 04:22:41 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.10 1998/08/04 16:44:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -462,8 +462,8 @@ create_nestloop_path(RelOptInfo *joinrel,
}
/*
* create_mergesort_path--
* Creates a pathnode corresponding to a mergesort join between
* create_mergejoin_path--
* Creates a pathnode corresponding to a mergejoin join between
* two relations
*
* 'joinrel' is the join relation
@@ -481,7 +481,7 @@ create_nestloop_path(RelOptInfo *joinrel,
*
*/
MergePath *
create_mergesort_path(RelOptInfo *joinrel,
create_mergejoin_path(RelOptInfo *joinrel,
int outersize,
int innersize,
int outerwidth,
@@ -509,7 +509,7 @@ create_mergesort_path(RelOptInfo *joinrel,
pathnode->outersortkeys = outersortkeys;
pathnode->innersortkeys = innersortkeys;
pathnode->jpath.path.path_cost =
cost_mergesort(outer_path->path_cost,
cost_mergejoin(outer_path->path_cost,
inner_path->path_cost,
outersortkeys,
innersortkeys,