mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
pgindent run over code.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.1 1999/02/18 19:58:53 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.2 1999/05/25 16:09:30 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -257,7 +257,7 @@ xfunc_llel_chains(Stream root, Stream bottom)
|
||||
*/
|
||||
Assert(xfunc_num_relids(pathstream) > xfunc_num_relids(tmpstream));
|
||||
progress = xfunc_prdmig_pullup(origstream, tmpstream,
|
||||
(JoinPath) get_pathptr(pathstream));
|
||||
(JoinPath) get_pathptr(pathstream));
|
||||
}
|
||||
if (get_downstream(tmpstream))
|
||||
pathstream = (Stream) xfunc_get_downjoin((Stream) get_downstream(tmpstream));
|
||||
@@ -269,7 +269,7 @@ xfunc_llel_chains(Stream root, Stream bottom)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_complete_stream
|
||||
** xfunc_complete_stream
|
||||
** Given a stream composed of join nodes only, make a copy containing the
|
||||
** join nodes along with the associated restriction nodes.
|
||||
*/
|
||||
@@ -313,7 +313,7 @@ xfunc_complete_stream(Stream stream)
|
||||
static bool
|
||||
xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath)
|
||||
{
|
||||
RestrictInfo restrictinfo = get_cinfo(pullme);
|
||||
RestrictInfo restrictinfo = get_cinfo(pullme);
|
||||
bool progress = false;
|
||||
Stream upjoin,
|
||||
orignode,
|
||||
@@ -347,10 +347,10 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath)
|
||||
else
|
||||
whichchild = INNER;
|
||||
restrictinfo = xfunc_pullup((Path) get_pathptr((Stream) get_downstream(upjoin)),
|
||||
(JoinPath) get_pathptr(upjoin),
|
||||
restrictinfo,
|
||||
whichchild,
|
||||
get_clausetype(orignode));
|
||||
(JoinPath) get_pathptr(upjoin),
|
||||
restrictinfo,
|
||||
whichchild,
|
||||
get_clausetype(orignode));
|
||||
set_pathptr(pullme, get_pathptr(upjoin));
|
||||
/* pullme has been moved into locrestrictinfo */
|
||||
set_clausetype(pullme, XFUNC_LOCPRD);
|
||||
@@ -390,7 +390,7 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_form_groups
|
||||
** xfunc_form_groups
|
||||
** A group is a pair of stream nodes a,b such that a is constrained to
|
||||
** precede b (for instance if a and b are both joins), but rank(a) > rank(b).
|
||||
** In such a situation, Monma and Sidney prove that no clauses should end
|
||||
@@ -487,10 +487,10 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom)
|
||||
}
|
||||
|
||||
|
||||
/* ------------------- UTILITY FUNCTIONS ------------------------- */
|
||||
/* ------------------- UTILITY FUNCTIONS ------------------------- */
|
||||
|
||||
/*
|
||||
** xfunc_free_stream
|
||||
** xfunc_free_stream
|
||||
** walk down a stream and pfree it
|
||||
*/
|
||||
static void
|
||||
@@ -525,7 +525,7 @@ xfunc_add_clauses(Stream current)
|
||||
foreach(temp, get_loc_restrictinfo((Path) get_pathptr(current)))
|
||||
{
|
||||
topnode = xfunc_streaminsert((RestrictInfo) lfirst(temp), topnode,
|
||||
XFUNC_LOCPRD);
|
||||
XFUNC_LOCPRD);
|
||||
}
|
||||
|
||||
/* and add in the join clauses */
|
||||
@@ -536,7 +536,7 @@ xfunc_add_clauses(Stream current)
|
||||
{
|
||||
if (!equal(get_clause((RestrictInfo) lfirst(temp)), primjoin))
|
||||
topnode = xfunc_streaminsert((RestrictInfo) lfirst(temp), topnode,
|
||||
XFUNC_JOINPRD);
|
||||
XFUNC_JOINPRD);
|
||||
}
|
||||
}
|
||||
return topnode;
|
||||
@@ -623,7 +623,7 @@ xfunc_num_relids(Stream node)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_get_downjoin
|
||||
** xfunc_get_downjoin
|
||||
** Given a stream node, find the next lowest node which points to a
|
||||
** join predicate or a scan node.
|
||||
*/
|
||||
@@ -642,7 +642,7 @@ xfunc_get_downjoin(Stream node)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_get_upjoin
|
||||
** xfunc_get_upjoin
|
||||
** same as above, but upwards.
|
||||
*/
|
||||
static StreamPtr
|
||||
@@ -660,7 +660,7 @@ xfunc_get_upjoin(Stream node)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_stream_qsort
|
||||
** xfunc_stream_qsort
|
||||
** Given a stream, sort by group rank the elements in the stream from the
|
||||
** node "bottom" up. DESTRUCTIVELY MODIFIES STREAM! Returns new root.
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.2 1999/05/10 00:45:14 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.3 1999/05/25 16:09:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ static int xfunc_card_unreferenced(Query *queryInfo,
|
||||
*/
|
||||
|
||||
/*
|
||||
** xfunc_trypullup
|
||||
** xfunc_trypullup
|
||||
** Preliminary pullup of predicates, to allow for maximal pruning.
|
||||
** Given a relation, check each of its paths and see if you can
|
||||
** pullup clauses from its inner and outer.
|
||||
@@ -59,7 +59,7 @@ void
|
||||
xfunc_trypullup(RelOptInfo rel)
|
||||
{
|
||||
LispValue y; /* list ptr */
|
||||
RestrictInfo maxcinfo; /* The RestrictInfo to pull up, as
|
||||
RestrictInfo maxcinfo; /* The RestrictInfo to pull up, as
|
||||
* calculated by xfunc_shouldpull() */
|
||||
JoinPath curpath; /* current path in list */
|
||||
int progress; /* has progress been made this time
|
||||
@@ -81,7 +81,7 @@ xfunc_trypullup(RelOptInfo rel)
|
||||
{
|
||||
/* No, the following should NOT be '==' !! */
|
||||
if (clausetype = xfunc_shouldpull((Path) get_innerjoinpath(curpath),
|
||||
curpath, INNER, &maxcinfo))
|
||||
curpath, INNER, &maxcinfo))
|
||||
{
|
||||
|
||||
xfunc_pullup((Path) get_innerjoinpath(curpath),
|
||||
@@ -96,7 +96,7 @@ xfunc_trypullup(RelOptInfo rel)
|
||||
|
||||
/* No, the following should NOT be '==' !! */
|
||||
if (clausetype = xfunc_shouldpull((Path) get_outerjoinpath(curpath),
|
||||
curpath, OUTER, &maxcinfo))
|
||||
curpath, OUTER, &maxcinfo))
|
||||
{
|
||||
|
||||
xfunc_pullup((Path) get_outerjoinpath(curpath),
|
||||
@@ -127,7 +127,7 @@ xfunc_trypullup(RelOptInfo rel)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_shouldpull
|
||||
** xfunc_shouldpull
|
||||
** find clause with highest rank, and decide whether to pull it up
|
||||
** from child to parent. Currently we only pullup secondary join clauses
|
||||
** that are in the pathrestrictinfo. Secondary hash and sort clauses are
|
||||
@@ -144,12 +144,12 @@ xfunc_shouldpull(Query *queryInfo,
|
||||
Path childpath,
|
||||
JoinPath parentpath,
|
||||
int whichchild,
|
||||
RestrictInfo *maxcinfopt) /* Out: pointer to clause
|
||||
RestrictInfo * maxcinfopt) /* Out: pointer to clause
|
||||
* to pullup */
|
||||
{
|
||||
LispValue clauselist,
|
||||
tmplist; /* lists of clauses */
|
||||
RestrictInfo maxcinfo; /* clause to pullup */
|
||||
RestrictInfo maxcinfo; /* clause to pullup */
|
||||
LispValue primjoinclause /* primary join clause */
|
||||
= xfunc_primary_join(parentpath);
|
||||
Cost tmprank,
|
||||
@@ -225,7 +225,7 @@ xfunc_shouldpull(Query *queryInfo,
|
||||
|| (!is_join(childpath)
|
||||
&& (whichchild == INNER)
|
||||
&& IsA(parentpath, NestPath)
|
||||
&&!IsA(parentpath, HashPath)
|
||||
&& !IsA(parentpath, HashPath)
|
||||
&&!IsA(parentpath, MergePath)))))
|
||||
{
|
||||
|
||||
@@ -250,7 +250,7 @@ xfunc_shouldpull(Query *queryInfo,
|
||||
|
||||
|
||||
/*
|
||||
** xfunc_pullup
|
||||
** xfunc_pullup
|
||||
** move clause from child pathnode to parent pathnode. This operation
|
||||
** makes the child pathnode produce a larger relation than it used to.
|
||||
** This means that we must construct a new RelOptInfo just for the childpath,
|
||||
@@ -264,7 +264,7 @@ RestrictInfo
|
||||
xfunc_pullup(Query *queryInfo,
|
||||
Path childpath,
|
||||
JoinPath parentpath,
|
||||
RestrictInfo cinfo, /* clause to pull up */
|
||||
RestrictInfo cinfo,/* clause to pull up */
|
||||
int whichchild, /* whether child is INNER or OUTER of join */
|
||||
int clausetype) /* whether clause to pull is join or local */
|
||||
{
|
||||
@@ -272,22 +272,22 @@ xfunc_pullup(Query *queryInfo,
|
||||
RelOptInfo newrel;
|
||||
Cost pulled_selec;
|
||||
Cost cost;
|
||||
RestrictInfo newinfo;
|
||||
RestrictInfo newinfo;
|
||||
|
||||
/* remove clause from childpath */
|
||||
newkid = (Path) copyObject((Node) childpath);
|
||||
if (clausetype == XFUNC_LOCPRD)
|
||||
{
|
||||
set_locrestrictinfo(newkid,
|
||||
xfunc_LispRemove((LispValue) cinfo,
|
||||
(List) get_loc_restrictinfo(newkid)));
|
||||
xfunc_LispRemove((LispValue) cinfo,
|
||||
(List) get_loc_restrictinfo(newkid)));
|
||||
}
|
||||
else
|
||||
{
|
||||
set_pathrestrictinfo
|
||||
((JoinPath) newkid,
|
||||
xfunc_LispRemove((LispValue) cinfo,
|
||||
(List) get_pathrestrictinfo((JoinPath) newkid)));
|
||||
(List) get_pathrestrictinfo((JoinPath) newkid)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -328,8 +328,8 @@ xfunc_pullup(Query *queryInfo,
|
||||
|
||||
/* add clause to parentpath, and fix up its cost. */
|
||||
set_locrestrictinfo(parentpath,
|
||||
lispCons((LispValue) newinfo,
|
||||
(LispValue) get_loc_restrictinfo(parentpath)));
|
||||
lispCons((LispValue) newinfo,
|
||||
(LispValue) get_loc_restrictinfo(parentpath)));
|
||||
/* put new childpath into the path tree */
|
||||
if (whichchild == INNER)
|
||||
set_innerjoinpath(parentpath, (pathPtr) newkid);
|
||||
@@ -386,7 +386,7 @@ LispValue clause;
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_join_expense
|
||||
** xfunc_join_expense
|
||||
** Find global expense of a join clause
|
||||
*/
|
||||
Cost
|
||||
@@ -457,7 +457,7 @@ xfunc_local_expense(LispValue clause)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_func_expense
|
||||
** xfunc_func_expense
|
||||
** given a Func or Oper and its args, find its expense.
|
||||
** Note: in Stonebraker's SIGMOD '91 paper, he uses a more complicated metric
|
||||
** than the one here. We can ignore the expected number of tuples for
|
||||
@@ -581,7 +581,7 @@ xfunc_func_expense(LispValue node, LispValue args)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_width
|
||||
** xfunc_width
|
||||
** recursively find the width of a expression
|
||||
*/
|
||||
|
||||
@@ -694,7 +694,7 @@ xfunc_width(LispValue clause)
|
||||
*/
|
||||
Assert(length(get_func_tlist(func)) == 1); /* sanity */
|
||||
retval = xfunc_width((LispValue)
|
||||
get_expr(lfirst(get_func_tlist(func))));
|
||||
get_expr(lfirst(get_func_tlist(func))));
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
@@ -771,8 +771,8 @@ xfunc_card_product(Query *queryInfo, Relids relids)
|
||||
{
|
||||
if (!xfunc_expense(queryInfo, get_clause((RestrictInfo) lfirst(cinfonode))))
|
||||
tuples *= compute_clause_selec(queryInfo,
|
||||
get_clause((RestrictInfo) lfirst(cinfonode)),
|
||||
LispNil);
|
||||
get_clause((RestrictInfo) lfirst(cinfonode)),
|
||||
LispNil);
|
||||
}
|
||||
|
||||
if (retval == 0)
|
||||
@@ -857,7 +857,7 @@ LispValue
|
||||
xfunc_primary_join(JoinPath pathnode)
|
||||
{
|
||||
LispValue joinclauselist = get_pathrestrictinfo(pathnode);
|
||||
RestrictInfo mincinfo;
|
||||
RestrictInfo mincinfo;
|
||||
LispValue tmplist;
|
||||
LispValue minclause = LispNil;
|
||||
Cost minrank,
|
||||
@@ -931,7 +931,7 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode)
|
||||
*/
|
||||
if (XfuncMode != XFUNC_OFF)
|
||||
set_locrestrictinfo(pathnode, lisp_qsort(get_loc_restrictinfo(pathnode),
|
||||
xfunc_cinfo_compare));
|
||||
xfunc_cinfo_compare));
|
||||
for (tmplist = get_loc_restrictinfo(pathnode), selec = 1.0;
|
||||
tmplist != LispNil;
|
||||
tmplist = lnext(tmplist))
|
||||
@@ -939,7 +939,7 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode)
|
||||
cost += (Cost) (xfunc_local_expense(get_clause((RestrictInfo) lfirst(tmplist)))
|
||||
* (Cost) get_tuples(get_parent(pathnode)) * selec);
|
||||
selec *= compute_clause_selec(queryInfo,
|
||||
get_clause((RestrictInfo) lfirst(tmplist)),
|
||||
get_clause((RestrictInfo) lfirst(tmplist)),
|
||||
LispNil);
|
||||
}
|
||||
|
||||
@@ -951,8 +951,8 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode)
|
||||
{
|
||||
if (XfuncMode != XFUNC_OFF)
|
||||
set_pathrestrictinfo((JoinPath) pathnode, lisp_qsort
|
||||
(get_pathrestrictinfo((JoinPath) pathnode),
|
||||
xfunc_cinfo_compare));
|
||||
(get_pathrestrictinfo((JoinPath) pathnode),
|
||||
xfunc_cinfo_compare));
|
||||
for (tmplist = get_pathrestrictinfo((JoinPath) pathnode), selec = 1.0;
|
||||
tmplist != LispNil;
|
||||
tmplist = lnext(tmplist))
|
||||
@@ -960,7 +960,7 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode)
|
||||
cost += (Cost) (xfunc_local_expense(get_clause((RestrictInfo) lfirst(tmplist)))
|
||||
* (Cost) get_tuples(get_parent(pathnode)) * selec);
|
||||
selec *= compute_clause_selec(queryInfo,
|
||||
get_clause((RestrictInfo) lfirst(tmplist)),
|
||||
get_clause((RestrictInfo) lfirst(tmplist)),
|
||||
LispNil);
|
||||
}
|
||||
}
|
||||
@@ -1071,7 +1071,7 @@ xfunc_total_path_cost(JoinPath pathnode)
|
||||
|
||||
|
||||
/*
|
||||
** xfunc_expense_per_tuple
|
||||
** xfunc_expense_per_tuple
|
||||
** return the expense of the join *per-tuple* of the input relation.
|
||||
** The cost model here is that a join costs
|
||||
** k*card(outer)*card(inner) + l*card(outer) + m*card(inner) + n
|
||||
@@ -1124,7 +1124,7 @@ xfunc_expense_per_tuple(JoinPath joinnode, int whichchild)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_fixvars
|
||||
** xfunc_fixvars
|
||||
** After pulling up a clause, we must walk its expression tree, fixing Var
|
||||
** nodes to point to the correct varno (either INNER or OUTER, depending
|
||||
** on which child the clause was pulled from), and the right varattno in the
|
||||
@@ -1189,8 +1189,8 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */
|
||||
int
|
||||
xfunc_cinfo_compare(void *arg1, void *arg2)
|
||||
{
|
||||
RestrictInfo info1 = *(RestrictInfo *) arg1;
|
||||
RestrictInfo info2 = *(RestrictInfo *) arg2;
|
||||
RestrictInfo info1 = *(RestrictInfo *) arg1;
|
||||
RestrictInfo info2 = *(RestrictInfo *) arg2;
|
||||
|
||||
LispValue clause1 = (LispValue) get_clause(info1),
|
||||
clause2 = (LispValue) get_clause(info2);
|
||||
@@ -1223,7 +1223,7 @@ xfunc_clause_compare(void *arg1, void *arg2)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_disjunct_sort
|
||||
** xfunc_disjunct_sort
|
||||
** given a list of clauses, for each clause sort the disjuncts by cost
|
||||
** (this assumes the predicates have been converted to Conjunctive NF)
|
||||
** Modifies the clause list!
|
||||
@@ -1287,7 +1287,7 @@ xfunc_disjunct_compare(Query *queryInfo, void *arg1, void *arg2)
|
||||
|
||||
/* ------------------------ UTILITY FUNCTIONS ------------------------------- */
|
||||
/*
|
||||
** xfunc_func_width
|
||||
** xfunc_func_width
|
||||
** Given a function OID and operands, find the width of the return value.
|
||||
*/
|
||||
int
|
||||
@@ -1349,7 +1349,7 @@ exit:
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_tuple_width
|
||||
** xfunc_tuple_width
|
||||
** Return the sum of the lengths of all the attributes of a given relation
|
||||
*/
|
||||
int
|
||||
@@ -1371,7 +1371,7 @@ xfunc_tuple_width(Relation rd)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_num_join_clauses
|
||||
** xfunc_num_join_clauses
|
||||
** Find the number of join clauses associated with this join path
|
||||
*/
|
||||
int
|
||||
@@ -1388,7 +1388,7 @@ xfunc_num_join_clauses(JoinPath path)
|
||||
}
|
||||
|
||||
/*
|
||||
** xfunc_LispRemove
|
||||
** xfunc_LispRemove
|
||||
** Just like LispRemove, but it whines if the item to be removed ain't there
|
||||
*/
|
||||
LispValue
|
||||
@@ -1419,11 +1419,11 @@ do { \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
** xfunc_copyrel
|
||||
** xfunc_copyrel
|
||||
** Just like _copyRel, but doesn't copy the paths
|
||||
*/
|
||||
bool
|
||||
xfunc_copyrel(RelOptInfo from, RelOptInfo *to)
|
||||
xfunc_copyrel(RelOptInfo from, RelOptInfo * to)
|
||||
{
|
||||
RelOptInfo newnode;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.44 1999/02/22 05:26:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.45 1999/05/25 16:09:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -45,10 +45,10 @@ int32 _use_geqo_rels_ = GEQO_RELS;
|
||||
|
||||
static void set_base_rel_pathlist(Query *root, List *rels);
|
||||
static RelOptInfo *make_one_rel_by_joins(Query *root, List *rels,
|
||||
int levels_needed);
|
||||
int levels_needed);
|
||||
|
||||
#ifdef OPTIMIZER_DEBUG
|
||||
static void debug_print_rel(Query *root, RelOptInfo *rel);
|
||||
static void debug_print_rel(Query *root, RelOptInfo * rel);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -76,6 +76,7 @@ make_one_rel(Query *root, List *rels)
|
||||
|
||||
if (levels_needed <= 1)
|
||||
{
|
||||
|
||||
/*
|
||||
* Unsorted single relation, no more processing is required.
|
||||
*/
|
||||
@@ -83,6 +84,7 @@ make_one_rel(Query *root, List *rels)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* This means that joins or sorts are required. set selectivities
|
||||
* of clauses that have not been set by an index.
|
||||
@@ -117,17 +119,17 @@ set_base_rel_pathlist(Query *root, List *rels)
|
||||
sequential_scan_list = lcons(create_seqscan_path(rel), NIL);
|
||||
|
||||
rel_index_scan_list = create_index_paths(root,
|
||||
rel,
|
||||
find_relation_indices(root, rel),
|
||||
rel->restrictinfo,
|
||||
rel->joininfo);
|
||||
rel,
|
||||
find_relation_indices(root, rel),
|
||||
rel->restrictinfo,
|
||||
rel->joininfo);
|
||||
|
||||
or_index_scan_list = create_or_index_paths(root, rel, rel->restrictinfo);
|
||||
|
||||
rel->pathlist = add_pathlist(rel,
|
||||
sequential_scan_list,
|
||||
nconc(rel_index_scan_list,
|
||||
or_index_scan_list));
|
||||
or_index_scan_list));
|
||||
|
||||
set_cheapest(rel, rel->pathlist);
|
||||
|
||||
@@ -171,13 +173,14 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed)
|
||||
*******************************************/
|
||||
if ((_use_geqo_) && length(root->base_rel_list) >= _use_geqo_rels_)
|
||||
return geqo(root);
|
||||
|
||||
|
||||
/*******************************************
|
||||
* rest will be deprecated in case of GEQO *
|
||||
*******************************************/
|
||||
|
||||
while (--levels_needed)
|
||||
{
|
||||
|
||||
/*
|
||||
* Determine all possible pairs of relations to be joined at this
|
||||
* level. Determine paths for joining these relation pairs and
|
||||
@@ -193,6 +196,7 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed)
|
||||
root->join_rel_list = rels = joined_rels;
|
||||
|
||||
#ifdef NOT_USED
|
||||
|
||||
/*
|
||||
* * for each expensive predicate in each path in each distinct
|
||||
* rel, * consider doing pullup -- JMH
|
||||
@@ -351,7 +355,7 @@ print_path(Query *root, Path *path, int indent)
|
||||
}
|
||||
|
||||
static void
|
||||
debug_print_rel(Query *root, RelOptInfo *rel)
|
||||
debug_print_rel(Query *root, RelOptInfo * rel)
|
||||
{
|
||||
List *l;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.19 1999/05/16 19:45:37 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.20 1999/05/25 16:09:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -132,7 +132,7 @@ set_rest_selec(Query *root, List *restrictinfo_list)
|
||||
if (cost_clause <= 0 || valid_or_clause(clausenode))
|
||||
{
|
||||
clausenode->selectivity = compute_clause_selec(root,
|
||||
(Node *) clausenode->clause,
|
||||
(Node *) clausenode->clause,
|
||||
lcons(makeFloat(cost_clause), NIL));
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ compute_selec(Query *root, List *clauses, List *or_selectivities)
|
||||
else if (not_clause((Node *) clause))
|
||||
{
|
||||
/* negate this baby */
|
||||
return 1 - compute_selec(root, ((Expr *)clause)->args, or_selectivities);
|
||||
return 1 - compute_selec(root, ((Expr *) clause)->args, or_selectivities);
|
||||
}
|
||||
else if (is_subplan((Node *) clause))
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.36 1999/05/01 19:47:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.37 1999/05/25 16:09:23 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,7 +37,7 @@
|
||||
extern int NBuffers;
|
||||
|
||||
static int compute_attribute_width(TargetEntry *tlistentry);
|
||||
static double relation_byte_size (int tuples, int width);
|
||||
static double relation_byte_size(int tuples, int width);
|
||||
static double base_log(double x, double b);
|
||||
static int compute_targetlist_width(List *targetlist);
|
||||
|
||||
@@ -134,9 +134,10 @@ cost_index(Oid indexid,
|
||||
if (!_enable_indexscan_ && !is_injoin)
|
||||
temp += _disable_cost_;
|
||||
|
||||
/* We want to be sure we estimate the cost of an index scan
|
||||
* as more than the cost of a sequential scan (when selec == 1.0),
|
||||
* even if we don't have good stats. So, disbelieve zero index size.
|
||||
/*
|
||||
* We want to be sure we estimate the cost of an index scan as more
|
||||
* than the cost of a sequential scan (when selec == 1.0), even if we
|
||||
* don't have good stats. So, disbelieve zero index size.
|
||||
*/
|
||||
if (expected_indexpages <= 0)
|
||||
expected_indexpages = 1;
|
||||
@@ -146,11 +147,11 @@ cost_index(Oid indexid,
|
||||
/* expected index relation pages */
|
||||
temp += expected_indexpages;
|
||||
|
||||
/* expected base relation pages
|
||||
* XXX this isn't really right, since we will access the table
|
||||
* nonsequentially and might have to fetch the same page
|
||||
* more than once. This calculation assumes the buffer cache
|
||||
* will prevent that from happening...
|
||||
/*
|
||||
* expected base relation pages XXX this isn't really right, since we
|
||||
* will access the table nonsequentially and might have to fetch the
|
||||
* same page more than once. This calculation assumes the buffer
|
||||
* cache will prevent that from happening...
|
||||
*/
|
||||
temp += ceil(((double) selec) * ((double) relpages));
|
||||
|
||||
@@ -192,8 +193,10 @@ cost_sort(List *pathkeys, int tuples, int width)
|
||||
if (!_enable_sort_)
|
||||
temp += _disable_cost_;
|
||||
|
||||
/* We want to be sure the cost of a sort is never estimated as zero,
|
||||
* even if passed-in tuple count is zero. Besides, mustn't do log(0)...
|
||||
/*
|
||||
* We want to be sure the cost of a sort is never estimated as zero,
|
||||
* even if passed-in tuple count is zero. Besides, mustn't do
|
||||
* log(0)...
|
||||
*/
|
||||
if (tuples <= 0)
|
||||
tuples = 1;
|
||||
@@ -344,10 +347,11 @@ cost_hashjoin(Cost outercost,
|
||||
if (!_enable_hashjoin_)
|
||||
temp += _disable_cost_;
|
||||
|
||||
/* Bias against putting larger relation on inside.
|
||||
/*
|
||||
* Bias against putting larger relation on inside.
|
||||
*
|
||||
* Code used to use "outerpages < innerpages" but that has
|
||||
* poor resolution when both relations are small.
|
||||
* Code used to use "outerpages < innerpages" but that has poor
|
||||
* resolution when both relations are small.
|
||||
*/
|
||||
if (relation_byte_size(outersize, outerwidth) <
|
||||
relation_byte_size(innersize, innerwidth))
|
||||
@@ -362,7 +366,8 @@ cost_hashjoin(Cost outercost,
|
||||
/* cost of main-memory hashtable */
|
||||
temp += (innerpages < NBuffers) ? innerpages : NBuffers;
|
||||
|
||||
/* if inner relation is too big then we will need to "batch" the join,
|
||||
/*
|
||||
* if inner relation is too big then we will need to "batch" the join,
|
||||
* which implies writing and reading most of the tuples to disk an
|
||||
* extra time.
|
||||
*/
|
||||
@@ -385,7 +390,7 @@ cost_hashjoin(Cost outercost,
|
||||
* Returns the size.
|
||||
*/
|
||||
int
|
||||
compute_rel_size(RelOptInfo *rel)
|
||||
compute_rel_size(RelOptInfo * rel)
|
||||
{
|
||||
Cost temp;
|
||||
int temp1;
|
||||
@@ -408,7 +413,7 @@ compute_rel_size(RelOptInfo *rel)
|
||||
* Returns the width of the tuple as a fixnum.
|
||||
*/
|
||||
int
|
||||
compute_rel_width(RelOptInfo *rel)
|
||||
compute_rel_width(RelOptInfo * rel)
|
||||
{
|
||||
return compute_targetlist_width(get_actual_tlist(rel->targetlist));
|
||||
}
|
||||
@@ -470,11 +475,11 @@ compute_joinrel_size(JoinPath *joinpath)
|
||||
temp *= ((Path *) joinpath->innerjoinpath)->parent->size;
|
||||
|
||||
temp = temp * product_selec(joinpath->pathinfo);
|
||||
if (temp >= (MAXINT-1)/2)
|
||||
if (temp >= (MAXINT - 1) / 2)
|
||||
{
|
||||
/* if we exceed (MAXINT-1)/2, we switch to log scale */
|
||||
/* +1 prevents log(0) */
|
||||
temp1 = ceil(log(temp + 1 - (MAXINT-1)/2) + (MAXINT-1)/2);
|
||||
temp1 = ceil(log(temp + 1 - (MAXINT - 1) / 2) + (MAXINT - 1) / 2);
|
||||
}
|
||||
else
|
||||
temp1 = ceil((double) temp);
|
||||
@@ -485,13 +490,13 @@ compute_joinrel_size(JoinPath *joinpath)
|
||||
|
||||
/*
|
||||
* relation_byte_size
|
||||
* Estimate the storage space in bytes for a given number of tuples
|
||||
* of a given width (size in bytes).
|
||||
* To avoid overflow with big relations, result is a double.
|
||||
* Estimate the storage space in bytes for a given number of tuples
|
||||
* of a given width (size in bytes).
|
||||
* To avoid overflow with big relations, result is a double.
|
||||
*/
|
||||
|
||||
static double
|
||||
relation_byte_size (int tuples, int width)
|
||||
relation_byte_size(int tuples, int width)
|
||||
{
|
||||
return ((double) tuples) * ((double) (width + sizeof(HeapTupleData)));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.15 1999/04/03 00:18:27 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.16 1999/05/25 16:09:23 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ static HashInfo *match_hashop_hashinfo(Oid hashop, List *hashinfo_list);
|
||||
*
|
||||
* 'restrictinfo_list' is the list of restrictinfo nodes
|
||||
* 'inner_relids' is the list of relids in the inner join relation
|
||||
* (used to determine whether a join var is inner or outer)
|
||||
* (used to determine whether a join var is inner or outer)
|
||||
*
|
||||
* Returns the new list of hashinfo nodes.
|
||||
*
|
||||
@@ -84,7 +84,7 @@ group_clauses_by_hashop(List *restrictinfo_list,
|
||||
}
|
||||
|
||||
xhashinfo->jmethod.clauses = lcons(clause,
|
||||
xhashinfo->jmethod.clauses);
|
||||
xhashinfo->jmethod.clauses);
|
||||
xhashinfo->jmethod.jmkeys = lcons(joinkey,
|
||||
xhashinfo->jmethod.jmkeys);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ static HashInfo *
|
||||
match_hashop_hashinfo(Oid hashop, List *hashinfo_list)
|
||||
{
|
||||
Oid key = 0;
|
||||
HashInfo *xhashinfo = (HashInfo *) NULL;
|
||||
HashInfo *xhashinfo = (HashInfo *) NULL;
|
||||
List *i = NIL;
|
||||
|
||||
foreach(i, hashinfo_list)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.54 1999/03/18 19:59:53 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.55 1999/05/25 16:09:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -45,32 +45,32 @@
|
||||
#include "utils/lsyscache.h"
|
||||
|
||||
|
||||
static void match_index_orclauses(RelOptInfo *rel, RelOptInfo *index, int indexkey,
|
||||
static void match_index_orclauses(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
||||
int xclass, List *restrictinfo_list);
|
||||
static bool match_index_to_operand(int indexkey, Expr *operand,
|
||||
RelOptInfo *rel, RelOptInfo *index);
|
||||
static List *match_index_orclause(RelOptInfo *rel, RelOptInfo *index, int indexkey,
|
||||
RelOptInfo * rel, RelOptInfo * index);
|
||||
static List *match_index_orclause(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
||||
int xclass, List *or_clauses, List *other_matching_indices);
|
||||
static List *group_clauses_by_indexkey(RelOptInfo *rel, RelOptInfo *index,
|
||||
int *indexkeys, Oid *classes, List *restrictinfo_list);
|
||||
static List *group_clauses_by_ikey_for_joins(RelOptInfo *rel, RelOptInfo *index,
|
||||
static List *group_clauses_by_indexkey(RelOptInfo * rel, RelOptInfo * index,
|
||||
int *indexkeys, Oid *classes, List *restrictinfo_list);
|
||||
static List *group_clauses_by_ikey_for_joins(RelOptInfo * rel, RelOptInfo * index,
|
||||
int *indexkeys, Oid *classes, List *join_cinfo_list, List *restr_cinfo_list);
|
||||
static RestrictInfo *match_clause_to_indexkey(RelOptInfo *rel, RelOptInfo *index, int indexkey,
|
||||
int xclass, RestrictInfo *restrictInfo, bool join);
|
||||
static RestrictInfo *match_clause_to_indexkey(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
||||
int xclass, RestrictInfo * restrictInfo, bool join);
|
||||
static bool pred_test(List *predicate_list, List *restrictinfo_list,
|
||||
List *joininfo_list);
|
||||
static bool one_pred_test(Expr *predicate, List *restrictinfo_list);
|
||||
static bool one_pred_clause_expr_test(Expr *predicate, Node *clause);
|
||||
static bool one_pred_clause_test(Expr *predicate, Node *clause);
|
||||
static bool clause_pred_clause_test(Expr *predicate, Node *clause);
|
||||
static List *indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index,
|
||||
static List *indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index,
|
||||
List *joininfo_list, List *restrictinfo_list);
|
||||
static List *index_innerjoin(Query *root, RelOptInfo *rel,
|
||||
List *clausegroup_list, RelOptInfo *index);
|
||||
static List *create_index_path_group(Query *root, RelOptInfo *rel, RelOptInfo *index,
|
||||
List *clausegroup_list, bool join);
|
||||
static List *index_innerjoin(Query *root, RelOptInfo * rel,
|
||||
List *clausegroup_list, RelOptInfo * index);
|
||||
static List *create_index_path_group(Query *root, RelOptInfo * rel, RelOptInfo * index,
|
||||
List *clausegroup_list, bool join);
|
||||
static List *add_index_paths(List *indexpaths, List *new_indexpaths);
|
||||
static bool function_index_operand(Expr *funcOpnd, RelOptInfo *rel, RelOptInfo *index);
|
||||
static bool function_index_operand(Expr *funcOpnd, RelOptInfo * rel, RelOptInfo * index);
|
||||
|
||||
|
||||
/* find_index_paths()
|
||||
@@ -100,10 +100,10 @@ static bool function_index_operand(Expr *funcOpnd, RelOptInfo *rel, RelOptInfo *
|
||||
*/
|
||||
List *
|
||||
create_index_paths(Query *root,
|
||||
RelOptInfo *rel,
|
||||
List *indices,
|
||||
List *restrictinfo_list,
|
||||
List *joininfo_list)
|
||||
RelOptInfo * rel,
|
||||
List *indices,
|
||||
List *restrictinfo_list,
|
||||
List *joininfo_list)
|
||||
{
|
||||
List *scanclausegroups = NIL;
|
||||
List *scanpaths = NIL;
|
||||
@@ -127,11 +127,11 @@ create_index_paths(Query *root,
|
||||
|
||||
/*
|
||||
* 1. Try matching the index against subclauses of an 'or' clause.
|
||||
* The fields of the restrictinfo nodes are marked with lists of the
|
||||
* matching indices. No path are actually created. We currently
|
||||
* only look to match the first key. We don't find multi-key
|
||||
* index cases where an AND matches the first key, and the OR
|
||||
* matches the second key.
|
||||
* The fields of the restrictinfo nodes are marked with lists of
|
||||
* the matching indices. No path are actually created. We
|
||||
* currently only look to match the first key. We don't find
|
||||
* multi-key index cases where an AND matches the first key, and
|
||||
* the OR matches the second key.
|
||||
*/
|
||||
match_index_orclauses(rel,
|
||||
index,
|
||||
@@ -144,7 +144,7 @@ create_index_paths(Query *root,
|
||||
* restriction clauses, then create pathnodes corresponding to
|
||||
* each group of usable clauses.
|
||||
*/
|
||||
scanclausegroups = group_clauses_by_indexkey(rel,
|
||||
scanclausegroups = group_clauses_by_indexkey(rel,
|
||||
index,
|
||||
index->indexkeys,
|
||||
index->classlist,
|
||||
@@ -153,10 +153,10 @@ create_index_paths(Query *root,
|
||||
scanpaths = NIL;
|
||||
if (scanclausegroups != NIL)
|
||||
scanpaths = create_index_path_group(root,
|
||||
rel,
|
||||
index,
|
||||
scanclausegroups,
|
||||
false);
|
||||
rel,
|
||||
index,
|
||||
scanclausegroups,
|
||||
false);
|
||||
|
||||
/*
|
||||
* 3. If this index can be used with any join clause, then create
|
||||
@@ -171,12 +171,12 @@ create_index_paths(Query *root,
|
||||
if (joinclausegroups != NIL)
|
||||
{
|
||||
joinpaths = create_index_path_group(root, rel,
|
||||
index,
|
||||
joinclausegroups,
|
||||
true);
|
||||
index,
|
||||
joinclausegroups,
|
||||
true);
|
||||
rel->innerjoin = nconc(rel->innerjoin,
|
||||
index_innerjoin(root, rel,
|
||||
joinclausegroups, index));
|
||||
joinclausegroups, index));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -217,8 +217,8 @@ create_index_paths(Query *root,
|
||||
*
|
||||
*/
|
||||
static void
|
||||
match_index_orclauses(RelOptInfo *rel,
|
||||
RelOptInfo *index,
|
||||
match_index_orclauses(RelOptInfo * rel,
|
||||
RelOptInfo * index,
|
||||
int indexkey,
|
||||
int xclass,
|
||||
List *restrictinfo_list)
|
||||
@@ -238,9 +238,9 @@ match_index_orclauses(RelOptInfo *rel,
|
||||
* 'index' to the existing list where appropriate.
|
||||
*/
|
||||
restrictinfo->indexids = match_index_orclause(rel, index, indexkey,
|
||||
xclass,
|
||||
restrictinfo->clause->args,
|
||||
restrictinfo->indexids);
|
||||
xclass,
|
||||
restrictinfo->clause->args,
|
||||
restrictinfo->indexids);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,8 +253,8 @@ match_index_orclauses(RelOptInfo *rel,
|
||||
static bool
|
||||
match_index_to_operand(int indexkey,
|
||||
Expr *operand,
|
||||
RelOptInfo *rel,
|
||||
RelOptInfo *index)
|
||||
RelOptInfo * rel,
|
||||
RelOptInfo * index)
|
||||
{
|
||||
bool result;
|
||||
|
||||
@@ -296,8 +296,8 @@ match_index_to_operand(int indexkey,
|
||||
* match the third, g,h match the fourth, etc.
|
||||
*/
|
||||
static List *
|
||||
match_index_orclause(RelOptInfo *rel,
|
||||
RelOptInfo *index,
|
||||
match_index_orclause(RelOptInfo * rel,
|
||||
RelOptInfo * index,
|
||||
int indexkey,
|
||||
int xclass,
|
||||
List *or_clauses,
|
||||
@@ -325,8 +325,9 @@ match_index_orclause(RelOptInfo *rel,
|
||||
|
||||
if (is_opclause(clause))
|
||||
{
|
||||
Expr *left = (Expr *) get_leftop((Expr *) clause);
|
||||
Expr *right = (Expr *) get_rightop((Expr *) clause);
|
||||
Expr *left = (Expr *) get_leftop((Expr *) clause);
|
||||
Expr *right = (Expr *) get_rightop((Expr *) clause);
|
||||
|
||||
if (left && right &&
|
||||
op_class(((Oper *) ((Expr *) clause)->oper)->opno,
|
||||
xclass, index->relam) &&
|
||||
@@ -335,7 +336,7 @@ match_index_orclause(RelOptInfo *rel,
|
||||
(IsA(left, Const) &&
|
||||
match_index_to_operand(indexkey, right, rel, index))))
|
||||
lfirst(matching_indices) = lcons(index,
|
||||
lfirst(matching_indices));
|
||||
lfirst(matching_indices));
|
||||
}
|
||||
|
||||
matching_indices = lnext(matching_indices);
|
||||
@@ -386,8 +387,8 @@ match_index_orclause(RelOptInfo *rel,
|
||||
*
|
||||
*/
|
||||
static List *
|
||||
group_clauses_by_indexkey(RelOptInfo *rel,
|
||||
RelOptInfo *index,
|
||||
group_clauses_by_indexkey(RelOptInfo * rel,
|
||||
RelOptInfo * index,
|
||||
int *indexkeys,
|
||||
Oid *classes,
|
||||
List *restrictinfo_list)
|
||||
@@ -448,8 +449,8 @@ group_clauses_by_indexkey(RelOptInfo *rel,
|
||||
*
|
||||
*/
|
||||
static List *
|
||||
group_clauses_by_ikey_for_joins(RelOptInfo *rel,
|
||||
RelOptInfo *index,
|
||||
group_clauses_by_ikey_for_joins(RelOptInfo * rel,
|
||||
RelOptInfo * index,
|
||||
int *indexkeys,
|
||||
Oid *classes,
|
||||
List *join_cinfo_list,
|
||||
@@ -570,11 +571,11 @@ group_clauses_by_ikey_for_joins(RelOptInfo *rel,
|
||||
*
|
||||
*/
|
||||
static RestrictInfo *
|
||||
match_clause_to_indexkey(RelOptInfo *rel,
|
||||
RelOptInfo *index,
|
||||
match_clause_to_indexkey(RelOptInfo * rel,
|
||||
RelOptInfo * index,
|
||||
int indexkey,
|
||||
int xclass,
|
||||
RestrictInfo *restrictInfo,
|
||||
RestrictInfo * restrictInfo,
|
||||
bool join)
|
||||
{
|
||||
Expr *clause = restrictInfo->clause;
|
||||
@@ -597,6 +598,7 @@ match_clause_to_indexkey(RelOptInfo *rel,
|
||||
*/
|
||||
if (!join)
|
||||
{
|
||||
|
||||
/*
|
||||
* Check for standard s-argable clause
|
||||
*/
|
||||
@@ -647,10 +649,10 @@ match_clause_to_indexkey(RelOptInfo *rel,
|
||||
restrict_op = oprid(newop);
|
||||
|
||||
isIndexable = (op_class(restrict_op, xclass, index->relam) &&
|
||||
IndexScanableOperand(leftop,
|
||||
indexkey,
|
||||
rel,
|
||||
index));
|
||||
IndexScanableOperand(leftop,
|
||||
indexkey,
|
||||
rel,
|
||||
index));
|
||||
|
||||
if (isIndexable)
|
||||
((Oper *) ((Expr *) clause)->oper)->opno = restrict_op;
|
||||
@@ -1181,7 +1183,7 @@ clause_pred_clause_test(Expr *predicate, Node *clause)
|
||||
*
|
||||
*/
|
||||
static List *
|
||||
indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index,
|
||||
indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index,
|
||||
List *joininfo_list, List *restrictinfo_list)
|
||||
{
|
||||
JoinInfo *joininfo = (JoinInfo *) NULL;
|
||||
@@ -1196,11 +1198,11 @@ indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index,
|
||||
if (joininfo->jinfo_restrictinfo == NIL)
|
||||
continue;
|
||||
clausegroups = group_clauses_by_ikey_for_joins(rel,
|
||||
index,
|
||||
index->indexkeys,
|
||||
index->classlist,
|
||||
index,
|
||||
index->indexkeys,
|
||||
index->classlist,
|
||||
joininfo->jinfo_restrictinfo,
|
||||
restrictinfo_list);
|
||||
restrictinfo_list);
|
||||
|
||||
if (clausegroups != NIL)
|
||||
{
|
||||
@@ -1253,8 +1255,8 @@ extract_restrict_clauses(List *clausegroup)
|
||||
*
|
||||
*/
|
||||
static List *
|
||||
index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list,
|
||||
RelOptInfo *index)
|
||||
index_innerjoin(Query *root, RelOptInfo * rel, List *clausegroup_list,
|
||||
RelOptInfo * index)
|
||||
{
|
||||
List *clausegroup = NIL;
|
||||
List *cg_list = NIL;
|
||||
@@ -1289,9 +1291,9 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list,
|
||||
pathnode->path.pathtype = T_IndexScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathorder = makeNode(PathOrder);
|
||||
pathnode->path.pathorder->ordtype = SORTOP_ORDER;
|
||||
pathnode->path.pathorder->ord.sortop = index->ordering;
|
||||
pathnode->path.pathkeys = NIL;
|
||||
pathnode->path.pathorder->ordtype = SORTOP_ORDER;
|
||||
pathnode->path.pathorder->ord.sortop = index->ordering;
|
||||
pathnode->path.pathkeys = NIL;
|
||||
|
||||
pathnode->indexid = index->relids;
|
||||
pathnode->indexkeys = index->indexkeys;
|
||||
@@ -1300,27 +1302,25 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list,
|
||||
pathnode->path.joinid = ((RestrictInfo *) lfirst(clausegroup))->restrictinfojoinid;
|
||||
|
||||
pathnode->path.path_cost = cost_index((Oid) lfirsti(index->relids),
|
||||
(int) temp_pages,
|
||||
temp_selec,
|
||||
rel->pages,
|
||||
rel->tuples,
|
||||
index->pages,
|
||||
index->tuples,
|
||||
true);
|
||||
(int) temp_pages,
|
||||
temp_selec,
|
||||
rel->pages,
|
||||
rel->tuples,
|
||||
index->pages,
|
||||
index->tuples,
|
||||
true);
|
||||
|
||||
/*
|
||||
* copy restrictinfo list into path for expensive function
|
||||
* processing -- JMH, 7/7/92
|
||||
*/
|
||||
pathnode->path.loc_restrictinfo = set_difference(copyObject((Node *) rel->restrictinfo),
|
||||
clausegroup);
|
||||
clausegroup);
|
||||
|
||||
#ifdef NOT_USED /* fix xfunc */
|
||||
#ifdef NOT_USED /* fix xfunc */
|
||||
/* add in cost for expensive functions! -- JMH, 7/7/92 */
|
||||
if (XfuncMode != XFUNC_OFF)
|
||||
{
|
||||
((Path *) pathnode)->path_cost += xfunc_get_path_cost((Path *) pathnode);
|
||||
}
|
||||
#endif
|
||||
cg_list = lappend(cg_list, pathnode);
|
||||
}
|
||||
@@ -1343,10 +1343,10 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list,
|
||||
*/
|
||||
static List *
|
||||
create_index_path_group(Query *root,
|
||||
RelOptInfo *rel,
|
||||
RelOptInfo *index,
|
||||
List *clausegroup_list,
|
||||
bool join)
|
||||
RelOptInfo * rel,
|
||||
RelOptInfo * index,
|
||||
List *clausegroup_list,
|
||||
bool join)
|
||||
{
|
||||
List *clausegroup = NIL;
|
||||
List *ip_list = NIL;
|
||||
@@ -1366,7 +1366,7 @@ create_index_path_group(Query *root,
|
||||
restrictinfo = (RestrictInfo *) lfirst(j);
|
||||
if (!(is_joinable((Node *) restrictinfo->clause) &&
|
||||
equal_path_merge_ordering(index->ordering,
|
||||
restrictinfo->mergejoinorder)))
|
||||
restrictinfo->mergejoinorder)))
|
||||
temp = false;
|
||||
}
|
||||
|
||||
@@ -1386,7 +1386,7 @@ add_index_paths(List *indexpaths, List *new_indexpaths)
|
||||
}
|
||||
|
||||
static bool
|
||||
function_index_operand(Expr *funcOpnd, RelOptInfo *rel, RelOptInfo *index)
|
||||
function_index_operand(Expr *funcOpnd, RelOptInfo * rel, RelOptInfo * index)
|
||||
{
|
||||
Oid heapRelid = (Oid) lfirsti(rel->relids);
|
||||
Func *function;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.36 1999/05/18 21:36:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.37 1999/05/25 16:09:25 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -30,14 +30,14 @@
|
||||
* _enable_mergejoin} */
|
||||
|
||||
static Path *best_innerjoin(List *join_paths, List *outer_relid);
|
||||
static List *sort_inner_and_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||
static List *sort_inner_and_outer(RelOptInfo * joinrel, RelOptInfo * outerrel, RelOptInfo * innerrel,
|
||||
List *mergeinfo_list);
|
||||
static List *match_unsorted_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||
static List *match_unsorted_outer(RelOptInfo * joinrel, RelOptInfo * outerrel, RelOptInfo * innerrel,
|
||||
List *outerpath_list, Path *cheapest_inner, Path *best_innerjoin,
|
||||
List *mergeinfo_list);
|
||||
static List *match_unsorted_inner(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||
static List *match_unsorted_inner(RelOptInfo * joinrel, RelOptInfo * outerrel, RelOptInfo * innerrel,
|
||||
List *innerpath_list, List *mergeinfo_list);
|
||||
static List *hash_inner_and_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||
static List *hash_inner_and_outer(RelOptInfo * joinrel, RelOptInfo * outerrel, RelOptInfo * innerrel,
|
||||
List *hashinfo_list);
|
||||
|
||||
/*
|
||||
@@ -119,13 +119,13 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels)
|
||||
* mergejoins where the outer path is already ordered.
|
||||
*/
|
||||
pathlist = add_pathlist(joinrel, pathlist,
|
||||
match_unsorted_outer(joinrel,
|
||||
outerrel,
|
||||
innerrel,
|
||||
outerrel->pathlist,
|
||||
innerrel->cheapestpath,
|
||||
bestinnerjoin,
|
||||
mergeinfo_list));
|
||||
match_unsorted_outer(joinrel,
|
||||
outerrel,
|
||||
innerrel,
|
||||
outerrel->pathlist,
|
||||
innerrel->cheapestpath,
|
||||
bestinnerjoin,
|
||||
mergeinfo_list));
|
||||
|
||||
/*
|
||||
* 3. Consider paths where the inner relation need not be
|
||||
@@ -134,18 +134,18 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels)
|
||||
* (match_unsorted_outer).
|
||||
*/
|
||||
pathlist = add_pathlist(joinrel, pathlist,
|
||||
match_unsorted_inner(joinrel, outerrel,
|
||||
innerrel,
|
||||
innerrel->pathlist,
|
||||
mergeinfo_list));
|
||||
match_unsorted_inner(joinrel, outerrel,
|
||||
innerrel,
|
||||
innerrel->pathlist,
|
||||
mergeinfo_list));
|
||||
|
||||
/*
|
||||
* 4. Consider paths where both outer and inner relations must be
|
||||
* hashed before being joined.
|
||||
*/
|
||||
pathlist = add_pathlist(joinrel, pathlist,
|
||||
hash_inner_and_outer(joinrel, outerrel,
|
||||
innerrel, hashinfo_list));
|
||||
hash_inner_and_outer(joinrel, outerrel,
|
||||
innerrel, hashinfo_list));
|
||||
|
||||
joinrel->pathlist = pathlist;
|
||||
}
|
||||
@@ -194,9 +194,9 @@ best_innerjoin(List *join_paths, Relids outer_relids)
|
||||
* Returns a list of mergejoin paths.
|
||||
*/
|
||||
static List *
|
||||
sort_inner_and_outer(RelOptInfo *joinrel,
|
||||
RelOptInfo *outerrel,
|
||||
RelOptInfo *innerrel,
|
||||
sort_inner_and_outer(RelOptInfo * joinrel,
|
||||
RelOptInfo * outerrel,
|
||||
RelOptInfo * innerrel,
|
||||
List *mergeinfo_list)
|
||||
{
|
||||
List *ms_list = NIL;
|
||||
@@ -212,28 +212,28 @@ sort_inner_and_outer(RelOptInfo *joinrel,
|
||||
xmergeinfo = (MergeInfo *) lfirst(i);
|
||||
|
||||
outerkeys = make_pathkeys_from_joinkeys(xmergeinfo->jmethod.jmkeys,
|
||||
outerrel->targetlist,
|
||||
OUTER);
|
||||
outerrel->targetlist,
|
||||
OUTER);
|
||||
|
||||
innerkeys = make_pathkeys_from_joinkeys(xmergeinfo->jmethod.jmkeys,
|
||||
innerrel->targetlist,
|
||||
INNER);
|
||||
innerrel->targetlist,
|
||||
INNER);
|
||||
|
||||
merge_pathkeys = new_join_pathkeys(outerkeys, joinrel->targetlist,
|
||||
xmergeinfo->jmethod.clauses);
|
||||
xmergeinfo->jmethod.clauses);
|
||||
|
||||
temp_node = create_mergejoin_path(joinrel,
|
||||
outerrel->size,
|
||||
innerrel->size,
|
||||
outerrel->width,
|
||||
innerrel->width,
|
||||
(Path *) outerrel->cheapestpath,
|
||||
(Path *) innerrel->cheapestpath,
|
||||
merge_pathkeys,
|
||||
xmergeinfo->m_ordering,
|
||||
xmergeinfo->jmethod.clauses,
|
||||
outerkeys,
|
||||
innerkeys);
|
||||
outerrel->size,
|
||||
innerrel->size,
|
||||
outerrel->width,
|
||||
innerrel->width,
|
||||
(Path *) outerrel->cheapestpath,
|
||||
(Path *) innerrel->cheapestpath,
|
||||
merge_pathkeys,
|
||||
xmergeinfo->m_ordering,
|
||||
xmergeinfo->jmethod.clauses,
|
||||
outerkeys,
|
||||
innerkeys);
|
||||
|
||||
ms_list = lappend(ms_list, temp_node);
|
||||
}
|
||||
@@ -268,9 +268,9 @@ sort_inner_and_outer(RelOptInfo *joinrel,
|
||||
* Returns a list of possible join path nodes.
|
||||
*/
|
||||
static List *
|
||||
match_unsorted_outer(RelOptInfo *joinrel,
|
||||
RelOptInfo *outerrel,
|
||||
RelOptInfo *innerrel,
|
||||
match_unsorted_outer(RelOptInfo * joinrel,
|
||||
RelOptInfo * outerrel,
|
||||
RelOptInfo * innerrel,
|
||||
List *outerpath_list,
|
||||
Path *cheapest_inner,
|
||||
Path *best_innerjoin,
|
||||
@@ -298,7 +298,7 @@ match_unsorted_outer(RelOptInfo *joinrel,
|
||||
|
||||
if (outerpath_ordering)
|
||||
xmergeinfo = match_order_mergeinfo(outerpath_ordering,
|
||||
mergeinfo_list);
|
||||
mergeinfo_list);
|
||||
|
||||
if (xmergeinfo)
|
||||
clauses = xmergeinfo->jmethod.clauses;
|
||||
@@ -308,13 +308,13 @@ match_unsorted_outer(RelOptInfo *joinrel,
|
||||
List *jmkeys = xmergeinfo->jmethod.jmkeys;
|
||||
|
||||
order_joinkeys_by_pathkeys(outerpath->pathkeys,
|
||||
jmkeys,
|
||||
clauses,
|
||||
OUTER,
|
||||
&matchedJoinKeys,
|
||||
&matchedJoinClauses);
|
||||
merge_pathkeys = new_join_pathkeys(outerpath->pathkeys,
|
||||
joinrel->targetlist, clauses);
|
||||
jmkeys,
|
||||
clauses,
|
||||
OUTER,
|
||||
&matchedJoinKeys,
|
||||
&matchedJoinClauses);
|
||||
merge_pathkeys = new_join_pathkeys(outerpath->pathkeys,
|
||||
joinrel->targetlist, clauses);
|
||||
}
|
||||
else
|
||||
merge_pathkeys = outerpath->pathkeys;
|
||||
@@ -338,21 +338,21 @@ match_unsorted_outer(RelOptInfo *joinrel,
|
||||
List *varkeys = NIL;
|
||||
Path *mergeinnerpath = get_cheapest_path_for_joinkeys(
|
||||
matchedJoinKeys,
|
||||
outerpath_ordering,
|
||||
innerrel->pathlist,
|
||||
INNER);
|
||||
outerpath_ordering,
|
||||
innerrel->pathlist,
|
||||
INNER);
|
||||
|
||||
/* Should we use the mergeinner, or sort the cheapest inner? */
|
||||
path_is_cheaper_than_sort = (bool) (mergeinnerpath &&
|
||||
(mergeinnerpath->path_cost <
|
||||
(cheapest_inner->path_cost +
|
||||
cost_sort(matchedJoinKeys, innerrel->size,
|
||||
innerrel->width))));
|
||||
(mergeinnerpath->path_cost <
|
||||
(cheapest_inner->path_cost +
|
||||
cost_sort(matchedJoinKeys, innerrel->size,
|
||||
innerrel->width))));
|
||||
if (!path_is_cheaper_than_sort)
|
||||
{
|
||||
varkeys = make_pathkeys_from_joinkeys(matchedJoinKeys,
|
||||
innerrel->targetlist,
|
||||
INNER);
|
||||
innerrel->targetlist,
|
||||
INNER);
|
||||
}
|
||||
|
||||
|
||||
@@ -368,18 +368,18 @@ match_unsorted_outer(RelOptInfo *joinrel,
|
||||
mergeinnerpath = cheapest_inner;
|
||||
|
||||
temp_node = lcons(create_mergejoin_path(joinrel,
|
||||
outerrel->size,
|
||||
innerrel->size,
|
||||
outerrel->width,
|
||||
innerrel->width,
|
||||
outerpath,
|
||||
mergeinnerpath,
|
||||
merge_pathkeys,
|
||||
xmergeinfo->m_ordering,
|
||||
matchedJoinClauses,
|
||||
NIL,
|
||||
varkeys),
|
||||
paths);
|
||||
outerrel->size,
|
||||
innerrel->size,
|
||||
outerrel->width,
|
||||
innerrel->width,
|
||||
outerpath,
|
||||
mergeinnerpath,
|
||||
merge_pathkeys,
|
||||
xmergeinfo->m_ordering,
|
||||
matchedJoinClauses,
|
||||
NIL,
|
||||
varkeys),
|
||||
paths);
|
||||
}
|
||||
else
|
||||
temp_node = paths;
|
||||
@@ -389,7 +389,7 @@ match_unsorted_outer(RelOptInfo *joinrel,
|
||||
}
|
||||
|
||||
/*
|
||||
* match_unsorted_inner
|
||||
* match_unsorted_inner
|
||||
* Find the cheapest ordered join path for a given(ordered, unsorted)
|
||||
* inner join path.
|
||||
*
|
||||
@@ -411,9 +411,9 @@ match_unsorted_outer(RelOptInfo *joinrel,
|
||||
* Returns a list of possible merge paths.
|
||||
*/
|
||||
static List *
|
||||
match_unsorted_inner(RelOptInfo *joinrel,
|
||||
RelOptInfo *outerrel,
|
||||
RelOptInfo *innerrel,
|
||||
match_unsorted_inner(RelOptInfo * joinrel,
|
||||
RelOptInfo * outerrel,
|
||||
RelOptInfo * innerrel,
|
||||
List *innerpath_list,
|
||||
List *mergeinfo_list)
|
||||
{
|
||||
@@ -441,11 +441,11 @@ match_unsorted_inner(RelOptInfo *joinrel,
|
||||
List *jmkeys = xmergeinfo->jmethod.jmkeys;
|
||||
|
||||
order_joinkeys_by_pathkeys(innerpath->pathkeys,
|
||||
jmkeys,
|
||||
clauses,
|
||||
INNER,
|
||||
&matchedJoinKeys,
|
||||
&matchedJoinClauses);
|
||||
jmkeys,
|
||||
clauses,
|
||||
INNER,
|
||||
&matchedJoinKeys,
|
||||
&matchedJoinClauses);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -459,29 +459,29 @@ match_unsorted_inner(RelOptInfo *joinrel,
|
||||
temp1 = outerrel->cheapestpath->path_cost +
|
||||
cost_sort(matchedJoinKeys, outerrel->size, outerrel->width);
|
||||
|
||||
if (innerpath->outerjoincost <= 0 /* unset? */
|
||||
if (innerpath->outerjoincost <= 0 /* unset? */
|
||||
|| innerpath->outerjoincost > temp1)
|
||||
{
|
||||
List *outerkeys = make_pathkeys_from_joinkeys(matchedJoinKeys,
|
||||
outerrel->targetlist,
|
||||
OUTER);
|
||||
outerrel->targetlist,
|
||||
OUTER);
|
||||
List *merge_pathkeys = new_join_pathkeys(outerkeys,
|
||||
joinrel->targetlist,
|
||||
clauses);
|
||||
joinrel->targetlist,
|
||||
clauses);
|
||||
|
||||
mp_list = lappend(mp_list,
|
||||
create_mergejoin_path(joinrel,
|
||||
outerrel->size,
|
||||
innerrel->size,
|
||||
outerrel->width,
|
||||
innerrel->width,
|
||||
outerrel->size,
|
||||
innerrel->size,
|
||||
outerrel->width,
|
||||
innerrel->width,
|
||||
(Path *) outerrel->cheapestpath,
|
||||
innerpath,
|
||||
merge_pathkeys,
|
||||
xmergeinfo->m_ordering,
|
||||
matchedJoinClauses,
|
||||
outerkeys,
|
||||
NIL));
|
||||
innerpath,
|
||||
merge_pathkeys,
|
||||
xmergeinfo->m_ordering,
|
||||
matchedJoinClauses,
|
||||
outerkeys,
|
||||
NIL));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -503,9 +503,9 @@ match_unsorted_inner(RelOptInfo *joinrel,
|
||||
* Returns a list of hashjoin paths.
|
||||
*/
|
||||
static List *
|
||||
hash_inner_and_outer(RelOptInfo *joinrel,
|
||||
RelOptInfo *outerrel,
|
||||
RelOptInfo *innerrel,
|
||||
hash_inner_and_outer(RelOptInfo * joinrel,
|
||||
RelOptInfo * outerrel,
|
||||
RelOptInfo * innerrel,
|
||||
List *hashinfo_list)
|
||||
{
|
||||
List *hjoin_list = NIL;
|
||||
@@ -520,20 +520,22 @@ hash_inner_and_outer(RelOptInfo *joinrel,
|
||||
HashPath *temp_node;
|
||||
|
||||
outerkeys = make_pathkeys_from_joinkeys(
|
||||
((JoinMethod *) xhashinfo)->jmkeys,
|
||||
outerrel->targetlist,
|
||||
OUTER);
|
||||
((JoinMethod *) xhashinfo)->jmkeys,
|
||||
outerrel->targetlist,
|
||||
OUTER);
|
||||
innerkeys = make_pathkeys_from_joinkeys(
|
||||
((JoinMethod *) xhashinfo)->jmkeys,
|
||||
innerrel->targetlist,
|
||||
INNER);
|
||||
/* We cannot assume that the output of the hashjoin appears in any
|
||||
((JoinMethod *) xhashinfo)->jmkeys,
|
||||
innerrel->targetlist,
|
||||
INNER);
|
||||
|
||||
/*
|
||||
* We cannot assume that the output of the hashjoin appears in any
|
||||
* particular order, so it should have NIL pathkeys.
|
||||
*/
|
||||
#ifdef NOT_USED
|
||||
hash_pathkeys = new_join_pathkeys(outerkeys,
|
||||
joinrel->targetlist,
|
||||
((JoinMethod *) xhashinfo)->clauses);
|
||||
joinrel->targetlist,
|
||||
((JoinMethod *) xhashinfo)->clauses);
|
||||
#else
|
||||
hash_pathkeys = NIL;
|
||||
#endif
|
||||
@@ -547,7 +549,7 @@ hash_inner_and_outer(RelOptInfo *joinrel,
|
||||
(Path *) innerrel->cheapestpath,
|
||||
hash_pathkeys,
|
||||
xhashinfo->hashop,
|
||||
((JoinMethod *) xhashinfo)->clauses,
|
||||
((JoinMethod *) xhashinfo)->clauses,
|
||||
outerkeys,
|
||||
innerkeys);
|
||||
hjoin_list = lappend(hjoin_list, temp_node);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.32 1999/02/22 06:08:48 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.33 1999/05/25 16:09:26 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -26,8 +26,8 @@
|
||||
static List *new_joininfo_list(List *joininfo_list, Relids join_relids);
|
||||
static bool nonoverlap_sets(List *s1, List *s2);
|
||||
static bool is_subset(List *s1, List *s2);
|
||||
static void set_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel,
|
||||
RelOptInfo *inner_rel, JoinInfo *jinfo);
|
||||
static void set_joinrel_size(RelOptInfo * joinrel, RelOptInfo * outer_rel,
|
||||
RelOptInfo * inner_rel, JoinInfo * jinfo);
|
||||
|
||||
/*
|
||||
* make_rels_by_joins
|
||||
@@ -52,18 +52,19 @@ make_rels_by_joins(Query *root, List *old_rels)
|
||||
RelOptInfo *old_rel = (RelOptInfo *) lfirst(r);
|
||||
|
||||
if (!(joined_rels = make_rels_by_clause_joins(root, old_rel,
|
||||
old_rel->joininfo,
|
||||
NIL)))
|
||||
old_rel->joininfo,
|
||||
NIL)))
|
||||
{
|
||||
|
||||
/*
|
||||
* Oops, we have a relation that is not joined to any other
|
||||
* relation. Cartesian product time.
|
||||
*/
|
||||
joined_rels = make_rels_by_clauseless_joins(old_rel,
|
||||
root->base_rel_list);
|
||||
root->base_rel_list);
|
||||
joined_rels = nconc(joined_rels,
|
||||
make_rels_by_clauseless_joins(old_rel,
|
||||
old_rels));
|
||||
old_rels));
|
||||
}
|
||||
|
||||
join_list = nconc(join_list, joined_rels);
|
||||
@@ -88,14 +89,14 @@ make_rels_by_joins(Query *root, List *old_rels)
|
||||
* Returns a list of new join relations.
|
||||
*/
|
||||
List *
|
||||
make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel,
|
||||
List *joininfo_list, Relids only_relids)
|
||||
make_rels_by_clause_joins(Query *root, RelOptInfo * old_rel,
|
||||
List *joininfo_list, Relids only_relids)
|
||||
{
|
||||
List *join_list = NIL;
|
||||
List *i = NIL;
|
||||
|
||||
foreach(i, joininfo_list)
|
||||
{
|
||||
{
|
||||
JoinInfo *joininfo = (JoinInfo *) lfirst(i);
|
||||
RelOptInfo *joined_rel;
|
||||
Relids unjoined_relids = joininfo->unjoined_relids;
|
||||
@@ -104,29 +105,29 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel,
|
||||
{
|
||||
if (length(unjoined_relids) == 1 &&
|
||||
(only_relids == NIL ||
|
||||
/* geqo only wants certain relids to make new rels */
|
||||
/* geqo only wants certain relids to make new rels */
|
||||
intMember(lfirsti(unjoined_relids), only_relids)))
|
||||
{
|
||||
joined_rel = make_join_rel(old_rel,
|
||||
get_base_rel(root,
|
||||
lfirsti(unjoined_relids)),
|
||||
joininfo);
|
||||
get_base_rel(root,
|
||||
lfirsti(unjoined_relids)),
|
||||
joininfo);
|
||||
join_list = lappend(join_list, joined_rel);
|
||||
|
||||
/* Right-sided plan */
|
||||
if (length(old_rel->relids) > 1)
|
||||
{
|
||||
joined_rel = make_join_rel(
|
||||
get_base_rel(root, lfirsti(unjoined_relids)),
|
||||
old_rel,
|
||||
joininfo);
|
||||
get_base_rel(root, lfirsti(unjoined_relids)),
|
||||
old_rel,
|
||||
joininfo);
|
||||
join_list = lappend(join_list, joined_rel);
|
||||
}
|
||||
}
|
||||
|
||||
if (only_relids == NIL) /* no bushy from geqo */
|
||||
if (only_relids == NIL) /* no bushy from geqo */
|
||||
{
|
||||
List *r;
|
||||
List *r;
|
||||
|
||||
foreach(r, root->join_rel_list)
|
||||
{
|
||||
@@ -134,11 +135,11 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel,
|
||||
|
||||
Assert(length(join_rel->relids) > 1);
|
||||
if (is_subset(unjoined_relids, join_rel->relids) &&
|
||||
nonoverlap_sets(old_rel->relids, join_rel->relids))
|
||||
nonoverlap_sets(old_rel->relids, join_rel->relids))
|
||||
{
|
||||
joined_rel = make_join_rel(old_rel,
|
||||
join_rel,
|
||||
joininfo);
|
||||
join_rel,
|
||||
joininfo);
|
||||
join_list = lappend(join_list, joined_rel);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +159,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel,
|
||||
* Returns a list of new join relations.
|
||||
*/
|
||||
List *
|
||||
make_rels_by_clauseless_joins(RelOptInfo *old_rel, List *inner_rels)
|
||||
make_rels_by_clauseless_joins(RelOptInfo * old_rel, List *inner_rels)
|
||||
{
|
||||
RelOptInfo *inner_rel;
|
||||
List *t_list = NIL;
|
||||
@@ -191,7 +192,7 @@ make_rels_by_clauseless_joins(RelOptInfo *old_rel, List *inner_rels)
|
||||
* Returns the new join relation node.
|
||||
*/
|
||||
RelOptInfo *
|
||||
make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo)
|
||||
make_join_rel(RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * joininfo)
|
||||
{
|
||||
RelOptInfo *joinrel = makeNode(RelOptInfo);
|
||||
List *joinrel_joininfo_list = NIL;
|
||||
@@ -203,7 +204,7 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo)
|
||||
* of the outer and inner join relations and then merging the results
|
||||
* together.
|
||||
*/
|
||||
new_outer_tlist = new_join_tlist(outer_rel->targetlist, 1);
|
||||
new_outer_tlist = new_join_tlist(outer_rel->targetlist, 1);
|
||||
new_inner_tlist = new_join_tlist(inner_rel->targetlist,
|
||||
length(new_outer_tlist) + 1);
|
||||
|
||||
@@ -224,8 +225,8 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo)
|
||||
joinrel->innerjoin = NIL;
|
||||
|
||||
/*
|
||||
* This function uses a trick to pass inner/outer rels as
|
||||
* different lists, and then flattens it out later. bjm
|
||||
* This function uses a trick to pass inner/outer rels as different
|
||||
* lists, and then flattens it out later. bjm
|
||||
*/
|
||||
joinrel->relids = lcons(outer_rel->relids, lcons(inner_rel->relids, NIL));
|
||||
|
||||
@@ -236,10 +237,10 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo)
|
||||
joinrel->restrictinfo = joininfo->jinfo_restrictinfo;
|
||||
|
||||
joinrel_joininfo_list = new_joininfo_list(
|
||||
nconc(copyObject(outer_rel->joininfo),
|
||||
copyObject(inner_rel->joininfo)),
|
||||
nconc(listCopy(outer_rel->relids),
|
||||
listCopy(inner_rel->relids)));
|
||||
nconc(copyObject(outer_rel->joininfo),
|
||||
copyObject(inner_rel->joininfo)),
|
||||
nconc(listCopy(outer_rel->relids),
|
||||
listCopy(inner_rel->relids)));
|
||||
|
||||
joinrel->joininfo = joinrel_joininfo_list;
|
||||
|
||||
@@ -278,12 +279,16 @@ new_join_tlist(List *tlist,
|
||||
foreach(i, tlist)
|
||||
{
|
||||
xtl = lfirst(i);
|
||||
/* XXX surely this is wrong? join_list is never changed? tgl 2/99 */
|
||||
|
||||
/*
|
||||
* XXX surely this is wrong? join_list is never changed? tgl
|
||||
* 2/99
|
||||
*/
|
||||
in_final_tlist = (join_list == NIL);
|
||||
if (in_final_tlist)
|
||||
{
|
||||
resdomno += 1;
|
||||
t_list = lappend(t_list,create_tl_element(get_expr(xtl), resdomno));
|
||||
t_list = lappend(t_list, create_tl_element(get_expr(xtl), resdomno));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,8 +340,8 @@ new_joininfo_list(List *joininfo_list, Relids join_relids)
|
||||
if (other_joininfo)
|
||||
{
|
||||
other_joininfo->jinfo_restrictinfo = (List *)
|
||||
LispUnion(joininfo->jinfo_restrictinfo,
|
||||
other_joininfo->jinfo_restrictinfo);
|
||||
LispUnion(joininfo->jinfo_restrictinfo,
|
||||
other_joininfo->jinfo_restrictinfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -393,7 +398,7 @@ get_cheapest_complete_rel(List *join_rel_list)
|
||||
}
|
||||
if (final)
|
||||
if (final_rel == NULL ||
|
||||
path_is_cheaper(rel->cheapestpath, final_rel->cheapestpath))
|
||||
path_is_cheaper(rel->cheapestpath, final_rel->cheapestpath))
|
||||
final_rel = rel;
|
||||
}
|
||||
|
||||
@@ -431,7 +436,7 @@ is_subset(List *s1, List *s2)
|
||||
}
|
||||
|
||||
static void
|
||||
set_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *jinfo)
|
||||
set_joinrel_size(RelOptInfo * joinrel, RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * jinfo)
|
||||
{
|
||||
int ntuples;
|
||||
float selec;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.21 1999/04/03 00:18:28 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.22 1999/05/25 16:09:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,7 +37,7 @@
|
||||
*
|
||||
* 'restrictinfo_list' is the list of restrictinfo nodes
|
||||
* 'inner_relids' is the list of relids in the inner join relation
|
||||
* (used to determine whether a join var is inner or outer)
|
||||
* (used to determine whether a join var is inner or outer)
|
||||
*
|
||||
* Returns the new list of mergeinfo nodes.
|
||||
*
|
||||
@@ -56,6 +56,7 @@ group_clauses_by_order(List *restrictinfo_list,
|
||||
|
||||
if (merge_ordering)
|
||||
{
|
||||
|
||||
/*
|
||||
* Create a new mergeinfo node and add it to 'mergeinfo_list'
|
||||
* if one does not yet exist for this merge ordering.
|
||||
@@ -63,8 +64,8 @@ group_clauses_by_order(List *restrictinfo_list,
|
||||
Expr *clause = restrictinfo->clause;
|
||||
Var *leftop = get_leftop(clause);
|
||||
Var *rightop = get_rightop(clause);
|
||||
PathOrder *pathorder;
|
||||
MergeInfo *xmergeinfo;
|
||||
PathOrder *pathorder;
|
||||
MergeInfo *xmergeinfo;
|
||||
JoinKey *jmkeys;
|
||||
|
||||
pathorder = makeNode(PathOrder);
|
||||
@@ -91,9 +92,9 @@ group_clauses_by_order(List *restrictinfo_list,
|
||||
}
|
||||
|
||||
xmergeinfo->jmethod.clauses = lcons(clause,
|
||||
xmergeinfo->jmethod.clauses);
|
||||
xmergeinfo->jmethod.clauses);
|
||||
xmergeinfo->jmethod.jmkeys = lcons(jmkeys,
|
||||
xmergeinfo->jmethod.jmkeys);
|
||||
xmergeinfo->jmethod.jmkeys);
|
||||
}
|
||||
}
|
||||
return mergeinfo_list;
|
||||
@@ -108,7 +109,7 @@ group_clauses_by_order(List *restrictinfo_list,
|
||||
* Returns the node if it exists.
|
||||
*
|
||||
*/
|
||||
MergeInfo *
|
||||
MergeInfo *
|
||||
match_order_mergeinfo(PathOrder *ordering, List *mergeinfo_list)
|
||||
{
|
||||
MergeOrder *xmergeorder;
|
||||
@@ -116,12 +117,12 @@ match_order_mergeinfo(PathOrder *ordering, List *mergeinfo_list)
|
||||
|
||||
foreach(xmergeinfo, mergeinfo_list)
|
||||
{
|
||||
MergeInfo *mergeinfo = (MergeInfo *) lfirst(xmergeinfo);
|
||||
MergeInfo *mergeinfo = (MergeInfo *) lfirst(xmergeinfo);
|
||||
|
||||
xmergeorder = mergeinfo->m_ordering;
|
||||
|
||||
if ((ordering->ordtype == MERGE_ORDER &&
|
||||
equal_merge_ordering(ordering->ord.merge, xmergeorder)) ||
|
||||
equal_merge_ordering(ordering->ord.merge, xmergeorder)) ||
|
||||
(ordering->ordtype == SORTOP_ORDER &&
|
||||
equal_path_merge_ordering(ordering->ord.sortop, xmergeorder)))
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.23 1999/03/08 14:01:55 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.24 1999/05/25 16:09:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -31,10 +31,9 @@
|
||||
#include "parser/parsetree.h"
|
||||
|
||||
|
||||
static void
|
||||
best_or_subclause_indices(Query *root, RelOptInfo *rel, List *subclauses,
|
||||
List *indices, List **indexids, Cost *cost, Cost *selec);
|
||||
static void best_or_subclause_index(Query *root, RelOptInfo *rel, Expr *subclause,
|
||||
static void best_or_subclause_indices(Query *root, RelOptInfo * rel, List *subclauses,
|
||||
List *indices, List **indexids, Cost *cost, Cost *selec);
|
||||
static void best_or_subclause_index(Query *root, RelOptInfo * rel, Expr *subclause,
|
||||
List *indices, int *indexid, Cost *cost, Cost *selec);
|
||||
|
||||
|
||||
@@ -50,7 +49,7 @@ static void best_or_subclause_index(Query *root, RelOptInfo *rel, Expr *subclaus
|
||||
*/
|
||||
List *
|
||||
create_or_index_paths(Query *root,
|
||||
RelOptInfo *rel, List *clauses)
|
||||
RelOptInfo * rel, List *clauses)
|
||||
{
|
||||
List *t_list = NIL;
|
||||
List *clist;
|
||||
@@ -88,7 +87,7 @@ create_or_index_paths(Query *root,
|
||||
IndexPath *pathnode = makeNode(IndexPath);
|
||||
List *indexids = NIL;
|
||||
Cost cost;
|
||||
Cost selec;
|
||||
Cost selec;
|
||||
|
||||
best_or_subclause_indices(root,
|
||||
rel,
|
||||
@@ -101,14 +100,15 @@ create_or_index_paths(Query *root,
|
||||
pathnode->path.pathtype = T_IndexScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathorder = makeNode(PathOrder);
|
||||
pathnode->path.pathorder->ordtype = SORTOP_ORDER;
|
||||
/*
|
||||
* This is an IndexScan, but it does index lookups based
|
||||
* on the order of the fields specified in the WHERE clause,
|
||||
* not in any order, so the sortop is NULL.
|
||||
pathnode->path.pathorder->ordtype = SORTOP_ORDER;
|
||||
|
||||
/*
|
||||
* This is an IndexScan, but it does index lookups based
|
||||
* on the order of the fields specified in the WHERE
|
||||
* clause, not in any order, so the sortop is NULL.
|
||||
*/
|
||||
pathnode->path.pathorder->ord.sortop = NULL;
|
||||
pathnode->path.pathkeys = NIL;
|
||||
pathnode->path.pathorder->ord.sortop = NULL;
|
||||
pathnode->path.pathkeys = NIL;
|
||||
|
||||
pathnode->indexqual = lcons(clausenode, NIL);
|
||||
pathnode->indexid = indexids;
|
||||
@@ -119,14 +119,12 @@ create_or_index_paths(Query *root,
|
||||
* processing -- JMH, 7/7/92
|
||||
*/
|
||||
pathnode->path.loc_restrictinfo = set_difference(copyObject((Node *) rel->restrictinfo),
|
||||
lcons(clausenode, NIL));
|
||||
lcons(clausenode, NIL));
|
||||
|
||||
#ifdef NOT_USED /* fix xfunc */
|
||||
#ifdef NOT_USED /* fix xfunc */
|
||||
/* add in cost for expensive functions! -- JMH, 7/7/92 */
|
||||
if (XfuncMode != XFUNC_OFF)
|
||||
{
|
||||
((Path *) pathnode)->path_cost += xfunc_get_path_cost((Path) pathnode);
|
||||
}
|
||||
#endif
|
||||
clausenode->selectivity = (Cost) selec;
|
||||
t_list = lappend(t_list, pathnode);
|
||||
@@ -158,18 +156,18 @@ create_or_index_paths(Query *root,
|
||||
*/
|
||||
static void
|
||||
best_or_subclause_indices(Query *root,
|
||||
RelOptInfo *rel,
|
||||
RelOptInfo * rel,
|
||||
List *subclauses,
|
||||
List *indices,
|
||||
List **indexids, /* return value */
|
||||
Cost *cost, /* return value */
|
||||
Cost *selec) /* return value */
|
||||
Cost *cost, /* return value */
|
||||
Cost *selec) /* return value */
|
||||
{
|
||||
List *slist;
|
||||
List *slist;
|
||||
|
||||
*selec = (Cost) 0.0;
|
||||
*cost = (Cost) 0.0;
|
||||
|
||||
|
||||
foreach(slist, subclauses)
|
||||
{
|
||||
int best_indexid;
|
||||
@@ -207,7 +205,7 @@ best_or_subclause_indices(Query *root,
|
||||
*/
|
||||
static void
|
||||
best_or_subclause_index(Query *root,
|
||||
RelOptInfo *rel,
|
||||
RelOptInfo * rel,
|
||||
Expr *subclause,
|
||||
List *indices,
|
||||
int *retIndexid, /* return value */
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.9 1999/05/17 00:26:33 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.10 1999/05/25 16:09:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -26,9 +26,9 @@
|
||||
#include "optimizer/ordering.h"
|
||||
|
||||
static int match_pathkey_joinkeys(List *pathkey, List *joinkeys,
|
||||
int outer_or_inner);
|
||||
int outer_or_inner);
|
||||
static List *new_join_pathkey(List *pathkeys, List *join_rel_tlist,
|
||||
List *joinclauses);
|
||||
List *joinclauses);
|
||||
|
||||
|
||||
/*--------------------
|
||||
@@ -41,7 +41,7 @@ static List *new_join_pathkey(List *pathkeys, List *join_rel_tlist,
|
||||
* of generating the relation and the resulting ordering of the tuples.
|
||||
* Sequential scan Paths have NIL pathkeys, indicating no known ordering.
|
||||
* Index scans have Path.pathkeys that represent the chosen index.
|
||||
* A single-key index pathkeys would be { {tab1_indexkey1} }. For a
|
||||
* A single-key index pathkeys would be { {tab1_indexkey1} }. For a
|
||||
* multi-key index pathkeys would be { {tab1_indexkey1}, {tab1_indexkey2} },
|
||||
* indicating major sort by indexkey1 and minor sort by indexkey2.
|
||||
*
|
||||
@@ -70,12 +70,12 @@ static List *new_join_pathkey(List *pathkeys, List *join_rel_tlist,
|
||||
* executor might have to split the join into multiple batches.
|
||||
*
|
||||
* NestJoin does not perform sorting, and allows non-equijoins, so it does
|
||||
* not allow useful pathkeys. (But couldn't we use the outer path's order?)
|
||||
* not allow useful pathkeys. (But couldn't we use the outer path's order?)
|
||||
*
|
||||
* -- bjm
|
||||
*--------------------
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* KEY COMPARISONS
|
||||
****************************************************************************/
|
||||
@@ -111,11 +111,11 @@ static List *new_join_pathkey(List *pathkeys, List *join_rel_tlist,
|
||||
*/
|
||||
bool
|
||||
order_joinkeys_by_pathkeys(List *pathkeys,
|
||||
List *joinkeys,
|
||||
List *joinclauses,
|
||||
int outer_or_inner,
|
||||
List **matchedJoinKeysPtr,
|
||||
List **matchedJoinClausesPtr)
|
||||
List *joinkeys,
|
||||
List *joinclauses,
|
||||
int outer_or_inner,
|
||||
List **matchedJoinKeysPtr,
|
||||
List **matchedJoinClausesPtr)
|
||||
{
|
||||
List *matched_joinkeys = NIL;
|
||||
List *matched_joinclauses = NIL;
|
||||
@@ -123,9 +123,10 @@ order_joinkeys_by_pathkeys(List *pathkeys,
|
||||
List *i = NIL;
|
||||
int matched_joinkey_index = -1;
|
||||
int matched_keys = 0;
|
||||
|
||||
/*
|
||||
* Reorder the joinkeys by picking out one that matches each pathkey,
|
||||
* and create a new joinkey/joinclause list in pathkey order
|
||||
* Reorder the joinkeys by picking out one that matches each pathkey,
|
||||
* and create a new joinkey/joinclause list in pathkey order
|
||||
*/
|
||||
foreach(i, pathkeys)
|
||||
{
|
||||
@@ -138,34 +139,36 @@ order_joinkeys_by_pathkeys(List *pathkeys,
|
||||
matched_keys++;
|
||||
if (matchedJoinKeysPtr)
|
||||
{
|
||||
JoinKey *joinkey = nth(matched_joinkey_index, joinkeys);
|
||||
JoinKey *joinkey = nth(matched_joinkey_index, joinkeys);
|
||||
|
||||
matched_joinkeys = lappend(matched_joinkeys, joinkey);
|
||||
}
|
||||
|
||||
|
||||
if (matchedJoinClausesPtr)
|
||||
{
|
||||
Expr *joinclause = nth(matched_joinkey_index,
|
||||
joinclauses);
|
||||
|
||||
Assert(joinclauses);
|
||||
matched_joinclauses = lappend(matched_joinclauses, joinclause);
|
||||
}
|
||||
}
|
||||
else
|
||||
/* A pathkey could not be matched. */
|
||||
/* A pathkey could not be matched. */
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Did we fail to match all the joinkeys?
|
||||
* Extra pathkeys are no problem.
|
||||
* Did we fail to match all the joinkeys? Extra pathkeys are no
|
||||
* problem.
|
||||
*/
|
||||
if (matched_keys != length(joinkeys))
|
||||
{
|
||||
if (matchedJoinKeysPtr)
|
||||
*matchedJoinKeysPtr = NIL;
|
||||
if (matchedJoinClausesPtr)
|
||||
*matchedJoinClausesPtr = NIL;
|
||||
return false;
|
||||
if (matchedJoinKeysPtr)
|
||||
*matchedJoinKeysPtr = NIL;
|
||||
if (matchedJoinClausesPtr)
|
||||
*matchedJoinClausesPtr = NIL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (matchedJoinKeysPtr)
|
||||
@@ -190,7 +193,8 @@ match_pathkey_joinkeys(List *pathkey,
|
||||
{
|
||||
Var *key;
|
||||
int pos;
|
||||
List *i, *x;
|
||||
List *i,
|
||||
*x;
|
||||
JoinKey *jk;
|
||||
|
||||
foreach(i, pathkey)
|
||||
@@ -232,9 +236,9 @@ match_pathkey_joinkeys(List *pathkey,
|
||||
*/
|
||||
Path *
|
||||
get_cheapest_path_for_joinkeys(List *joinkeys,
|
||||
PathOrder *ordering,
|
||||
List *paths,
|
||||
int outer_or_inner)
|
||||
PathOrder *ordering,
|
||||
List *paths,
|
||||
int outer_or_inner)
|
||||
{
|
||||
Path *matched_path = NULL;
|
||||
List *i;
|
||||
@@ -243,7 +247,7 @@ get_cheapest_path_for_joinkeys(List *joinkeys,
|
||||
{
|
||||
Path *path = (Path *) lfirst(i);
|
||||
int better_sort;
|
||||
|
||||
|
||||
if (order_joinkeys_by_pathkeys(path->pathkeys, joinkeys, NIL,
|
||||
outer_or_inner, NULL, NULL) &&
|
||||
pathorder_match(ordering, path->pathorder, &better_sort) &&
|
||||
@@ -274,8 +278,8 @@ get_cheapest_path_for_joinkeys(List *joinkeys,
|
||||
*/
|
||||
List *
|
||||
make_pathkeys_from_joinkeys(List *joinkeys,
|
||||
List *tlist,
|
||||
int outer_or_inner)
|
||||
List *tlist,
|
||||
int outer_or_inner)
|
||||
{
|
||||
List *pathkeys = NIL;
|
||||
List *jk;
|
||||
@@ -284,7 +288,8 @@ make_pathkeys_from_joinkeys(List *joinkeys,
|
||||
{
|
||||
JoinKey *jkey = (JoinKey *) lfirst(jk);
|
||||
Var *key;
|
||||
List *p, *p2;
|
||||
List *p,
|
||||
*p2;
|
||||
bool found = false;
|
||||
|
||||
key = (Var *) extract_join_key(jkey, outer_or_inner);
|
||||
@@ -292,17 +297,19 @@ make_pathkeys_from_joinkeys(List *joinkeys,
|
||||
/* check to see if it is in the target list */
|
||||
if (matching_tlist_var(key, tlist))
|
||||
{
|
||||
|
||||
/*
|
||||
* Include it in the pathkeys list if we haven't already done so
|
||||
* Include it in the pathkeys list if we haven't already done
|
||||
* so
|
||||
*/
|
||||
foreach(p, pathkeys)
|
||||
{
|
||||
List *pathkey = lfirst(p);
|
||||
|
||||
|
||||
foreach(p2, pathkey)
|
||||
{
|
||||
Var *pkey = lfirst(p2);
|
||||
|
||||
|
||||
if (equal(key, pkey))
|
||||
{
|
||||
found = true;
|
||||
@@ -371,7 +378,7 @@ new_join_pathkeys(List *outer_pathkeys,
|
||||
*
|
||||
* Note that each returned pathkey is the var node found in
|
||||
* 'join_rel_tlist' rather than the joinclause var node.
|
||||
* (Is this important?) Also, we return a fully copied list
|
||||
* (Is this important?) Also, we return a fully copied list
|
||||
* that does not share any subnodes with existing data structures.
|
||||
* (Is that important, either?)
|
||||
*
|
||||
@@ -393,7 +400,7 @@ new_join_pathkey(List *pathkey,
|
||||
Expr *tlist_key;
|
||||
|
||||
Assert(key);
|
||||
|
||||
|
||||
tlist_key = matching_tlist_var(key, join_rel_tlist);
|
||||
if (tlist_key && !member(tlist_key, new_pathkey))
|
||||
new_pathkey = lcons(copyObject(tlist_key), new_pathkey);
|
||||
@@ -404,8 +411,8 @@ new_join_pathkey(List *pathkey,
|
||||
Expr *tlist_other_var;
|
||||
|
||||
tlist_other_var = matching_tlist_var(
|
||||
other_join_clause_var(key, joinclause),
|
||||
join_rel_tlist);
|
||||
other_join_clause_var(key, joinclause),
|
||||
join_rel_tlist);
|
||||
if (tlist_other_var && !member(tlist_other_var, new_pathkey))
|
||||
new_pathkey = lcons(copyObject(tlist_other_var), new_pathkey);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.37 1999/02/18 00:49:21 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.38 1999/05/25 16:09:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "utils/elog.h"
|
||||
|
||||
|
||||
static List *merge_rel_with_same_relids(RelOptInfo *rel, Relids unjoined_relids);
|
||||
static List *merge_rel_with_same_relids(RelOptInfo * rel, Relids unjoined_relids);
|
||||
|
||||
/*
|
||||
* merge_rels_with_same_relids
|
||||
@@ -59,7 +59,7 @@ merge_rels_with_same_relids(List *rel_list)
|
||||
*
|
||||
*/
|
||||
static List *
|
||||
merge_rel_with_same_relids(RelOptInfo *rel, Relids unjoined_relids)
|
||||
merge_rel_with_same_relids(RelOptInfo * rel, Relids unjoined_relids)
|
||||
{
|
||||
List *i = NIL;
|
||||
List *result = NIL;
|
||||
@@ -69,9 +69,10 @@ merge_rel_with_same_relids(RelOptInfo *rel, Relids unjoined_relids)
|
||||
RelOptInfo *unjoined_rel = (RelOptInfo *) lfirst(i);
|
||||
|
||||
if (same(rel->relids, unjoined_rel->relids))
|
||||
|
||||
/*
|
||||
* This are on the same relations,
|
||||
* so get the best of their pathlists.
|
||||
* This are on the same relations, so get the best of their
|
||||
* pathlists.
|
||||
*/
|
||||
rel->pathlist = add_pathlist(rel,
|
||||
rel->pathlist,
|
||||
@@ -92,7 +93,7 @@ rels_set_cheapest(List *rel_list)
|
||||
{
|
||||
List *x = NIL;
|
||||
RelOptInfo *rel = (RelOptInfo *) NULL;
|
||||
JoinPath *cheapest;
|
||||
JoinPath *cheapest;
|
||||
|
||||
foreach(x, rel_list)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user