mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.10 2001/03/22 06:16:14 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.11 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -244,7 +244,6 @@ xfunc_llel_chains(Stream root, Stream bottom)
|
||||
if (is_clause(tmpstream)
|
||||
&& get_pathptr(pathstream) != get_pathptr(tmpstream))
|
||||
{
|
||||
|
||||
/*
|
||||
* * If restriction moved above a Join after sort, we pull it *
|
||||
* up in the join plan. * If restriction moved down, we
|
||||
@@ -470,7 +469,7 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom)
|
||||
get_groupup((Stream) get_downstream(temp))) &&
|
||||
get_grouprank(parent) < get_grouprank(temp))
|
||||
{
|
||||
progress = true;/* we formed a new group */
|
||||
progress = true; /* we formed a new group */
|
||||
set_groupup(temp, true);
|
||||
set_groupcost(temp,
|
||||
get_groupcost(temp) +
|
||||
@@ -485,7 +484,7 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom)
|
||||
}
|
||||
|
||||
|
||||
/* ------------------- UTILITY FUNCTIONS ------------------------- */
|
||||
/* ------------------- UTILITY FUNCTIONS ------------------------- */
|
||||
|
||||
/*
|
||||
** xfunc_free_stream
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.16 2001/03/22 06:16:14 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.17 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -237,7 +237,6 @@ xfunc_shouldpull(Query *queryInfo,
|
||||
}
|
||||
else if (maxrank != -(MAXFLOAT))
|
||||
{
|
||||
|
||||
/*
|
||||
* * we've left an expensive restriction below a join. Since *
|
||||
* we may pullup this restriction in predmig.c, we'd best *
|
||||
@@ -656,7 +655,6 @@ xfunc_width(LispValue clause)
|
||||
}
|
||||
else if (IsA(clause, Iter))
|
||||
{
|
||||
|
||||
/*
|
||||
* * An Iter returns a setof things, so return the width of a
|
||||
* single * thing. * Note: THIS MAY NOT WORK RIGHT WHEN AGGS GET
|
||||
@@ -668,7 +666,6 @@ xfunc_width(LispValue clause)
|
||||
}
|
||||
else if (fast_is_clause(clause))
|
||||
{
|
||||
|
||||
/*
|
||||
* * get function associated with this Oper, and treat this as * a
|
||||
* Func
|
||||
@@ -689,7 +686,6 @@ xfunc_width(LispValue clause)
|
||||
|
||||
if (get_func_tlist(func) != LispNil)
|
||||
{
|
||||
|
||||
/*
|
||||
* this function has a projection on it. Get the length of
|
||||
* the projected attribute
|
||||
@@ -1150,7 +1146,6 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */
|
||||
tle = tlistentry_member((Var) clause, get_targetlist(rel));
|
||||
if (tle == LispNil)
|
||||
{
|
||||
|
||||
/*
|
||||
* * The attribute we need is not in the target list, * so we
|
||||
* have to add it. *
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.79 2001/10/18 16:11:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.80 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,10 +38,10 @@ static void set_base_rel_pathlists(Query *root);
|
||||
static void set_plain_rel_pathlist(Query *root, RelOptInfo *rel,
|
||||
RangeTblEntry *rte);
|
||||
static void set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
|
||||
Index rti, RangeTblEntry *rte,
|
||||
List *inheritlist);
|
||||
Index rti, RangeTblEntry *rte,
|
||||
List *inheritlist);
|
||||
static void set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
Index rti, RangeTblEntry *rte);
|
||||
Index rti, RangeTblEntry *rte);
|
||||
static RelOptInfo *make_one_rel_by_joins(Query *root, int levels_needed,
|
||||
List *initial_rels);
|
||||
|
||||
@@ -160,7 +160,7 @@ set_plain_rel_pathlist(Query *root, RelOptInfo *rel, RangeTblEntry *rte)
|
||||
* Build access paths for a inheritance tree rooted at rel
|
||||
*
|
||||
* inheritlist is a list of RT indexes of all tables in the inheritance tree,
|
||||
* including a duplicate of the parent itself. Note we will not come here
|
||||
* including a duplicate of the parent itself. Note we will not come here
|
||||
* unless there's at least one child in addition to the parent.
|
||||
*
|
||||
* NOTE: the passed-in rel and RTE will henceforth represent the appended
|
||||
@@ -192,9 +192,9 @@ set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
|
||||
elog(ERROR, "SELECT FOR UPDATE is not supported for inherit queries");
|
||||
|
||||
/*
|
||||
* The executor will check the parent table's access permissions when it
|
||||
* examines the parent's inheritlist entry. There's no need to check
|
||||
* twice, so turn off access check bits in the original RTE.
|
||||
* The executor will check the parent table's access permissions when
|
||||
* it examines the parent's inheritlist entry. There's no need to
|
||||
* check twice, so turn off access check bits in the original RTE.
|
||||
*/
|
||||
rte->checkForRead = false;
|
||||
rte->checkForWrite = false;
|
||||
@@ -230,8 +230,8 @@ set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
|
||||
/*
|
||||
* Copy the parent's targetlist and restriction quals to the
|
||||
* child, with attribute-number adjustment as needed. We don't
|
||||
* bother to copy the join quals, since we can't do any joining
|
||||
* of the individual tables.
|
||||
* bother to copy the join quals, since we can't do any joining of
|
||||
* the individual tables.
|
||||
*/
|
||||
childrel->targetlist = (List *)
|
||||
adjust_inherited_attrs((Node *) rel->targetlist,
|
||||
@@ -282,32 +282,32 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
|
||||
/*
|
||||
* If there are any restriction clauses that have been attached to the
|
||||
* subquery relation, consider pushing them down to become HAVING quals
|
||||
* of the subquery itself. (Not WHERE clauses, since they may refer to
|
||||
* subquery outputs that are aggregate results. But planner.c will
|
||||
* transfer them into the subquery's WHERE if they do not.) This
|
||||
* transformation is useful because it may allow us to generate a better
|
||||
* plan for the subquery than evaluating all the subquery output rows
|
||||
* and then filtering them.
|
||||
* subquery relation, consider pushing them down to become HAVING
|
||||
* quals of the subquery itself. (Not WHERE clauses, since they may
|
||||
* refer to subquery outputs that are aggregate results. But
|
||||
* planner.c will transfer them into the subquery's WHERE if they do
|
||||
* not.) This transformation is useful because it may allow us to
|
||||
* generate a better plan for the subquery than evaluating all the
|
||||
* subquery output rows and then filtering them.
|
||||
*
|
||||
* There are several cases where we cannot push down clauses:
|
||||
*
|
||||
* 1. If the subquery contains set ops (UNION/INTERSECT/EXCEPT) we do not
|
||||
* push down any qual clauses, since the planner doesn't support quals at
|
||||
* the top level of a setop. (With suitable analysis we could try to push
|
||||
* the quals down into the component queries of the setop, but getting it
|
||||
* right seems nontrivial. Work on this later.)
|
||||
* push down any qual clauses, since the planner doesn't support quals
|
||||
* at the top level of a setop. (With suitable analysis we could try
|
||||
* to push the quals down into the component queries of the setop, but
|
||||
* getting it right seems nontrivial. Work on this later.)
|
||||
*
|
||||
* 2. If the subquery has a LIMIT clause or a DISTINCT ON clause, we must
|
||||
* not push down any quals, since that could change the set of rows
|
||||
* returned. (Actually, we could push down quals into a DISTINCT ON
|
||||
* subquery if they refer only to DISTINCT-ed output columns, but checking
|
||||
* that seems more work than it's worth. In any case, a plain DISTINCT is
|
||||
* safe to push down past.)
|
||||
* subquery if they refer only to DISTINCT-ed output columns, but
|
||||
* checking that seems more work than it's worth. In any case, a
|
||||
* plain DISTINCT is safe to push down past.)
|
||||
*
|
||||
* 3. We do not push down clauses that contain subselects, mainly because
|
||||
* I'm not sure it will work correctly (the subplan hasn't yet transformed
|
||||
* sublinks to subselects).
|
||||
* I'm not sure it will work correctly (the subplan hasn't yet
|
||||
* transformed sublinks to subselects).
|
||||
*
|
||||
* Non-pushed-down clauses will get evaluated as qpquals of the
|
||||
* SubqueryScan node.
|
||||
@@ -337,22 +337,23 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
else
|
||||
{
|
||||
/*
|
||||
* We need to replace Vars in the clause (which must refer to
|
||||
* outputs of the subquery) with copies of the subquery's
|
||||
* targetlist expressions. Note that at this point, any
|
||||
* uplevel Vars in the clause should have been replaced with
|
||||
* Params, so they need no work.
|
||||
* We need to replace Vars in the clause (which must refer
|
||||
* to outputs of the subquery) with copies of the
|
||||
* subquery's targetlist expressions. Note that at this
|
||||
* point, any uplevel Vars in the clause should have been
|
||||
* replaced with Params, so they need no work.
|
||||
*/
|
||||
clause = ResolveNew(clause, rti, 0,
|
||||
subquery->targetList,
|
||||
CMD_SELECT, 0);
|
||||
subquery->havingQual = make_and_qual(subquery->havingQual,
|
||||
clause);
|
||||
|
||||
/*
|
||||
* We need not change the subquery's hasAggs or
|
||||
* hasSublinks flags, since we can't be pushing
|
||||
* down any aggregates that weren't there before,
|
||||
* and we don't push down subselects at all.
|
||||
* hasSublinks flags, since we can't be pushing down any
|
||||
* aggregates that weren't there before, and we don't push
|
||||
* down subselects at all.
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -412,7 +413,6 @@ make_fromexpr_rel(Query *root, FromExpr *from)
|
||||
|
||||
if (levels_needed == 1)
|
||||
{
|
||||
|
||||
/*
|
||||
* Single jointree node, so we're done.
|
||||
*/
|
||||
@@ -420,7 +420,6 @@ make_fromexpr_rel(Query *root, FromExpr *from)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* Consider the different orders in which we could join the rels,
|
||||
* using either GEQO or regular optimizer.
|
||||
@@ -552,7 +551,7 @@ print_restrictclauses(Query *root, List *clauses)
|
||||
static void
|
||||
print_path(Query *root, Path *path, int indent)
|
||||
{
|
||||
const char *ptype;
|
||||
const char *ptype;
|
||||
bool join;
|
||||
int i;
|
||||
|
||||
@@ -650,7 +649,7 @@ debug_print_rel(Query *root, RelOptInfo *rel)
|
||||
|
||||
foreach(l, rel->joininfo)
|
||||
{
|
||||
JoinInfo *j = (JoinInfo *) lfirst(l);
|
||||
JoinInfo *j = (JoinInfo *) lfirst(l);
|
||||
|
||||
printf("\tjoininfo (");
|
||||
print_relids(j->unjoined_relids);
|
||||
@@ -669,5 +668,4 @@ debug_print_rel(Query *root, RelOptInfo *rel)
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
#endif /* OPTIMIZER_DEBUG */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.46 2001/06/25 21:11:43 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.47 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ typedef struct RangeQueryClause
|
||||
} RangeQueryClause;
|
||||
|
||||
static void addRangeClause(RangeQueryClause **rqlist, Node *clause,
|
||||
bool varonleft, bool isLTsel, Selectivity s2);
|
||||
bool varonleft, bool isLTsel, Selectivity s2);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
@@ -212,7 +212,6 @@ clauselist_selectivity(Query *root,
|
||||
{
|
||||
if (s2 < -0.01)
|
||||
{
|
||||
|
||||
/*
|
||||
* No data available --- use a default estimate that
|
||||
* is small, but not real small.
|
||||
@@ -221,7 +220,6 @@ clauselist_selectivity(Query *root,
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* It's just roundoff error; use a small positive
|
||||
* value
|
||||
@@ -275,7 +273,6 @@ addRangeClause(RangeQueryClause **rqlist, Node *clause,
|
||||
|
||||
for (rqelem = *rqlist; rqelem; rqelem = rqelem->next)
|
||||
{
|
||||
|
||||
/*
|
||||
* We use full equal() here because the "var" might be a function
|
||||
* of one or more attributes of the same relation...
|
||||
@@ -386,7 +383,6 @@ clause_selectivity(Query *root,
|
||||
|
||||
if (rte->subquery)
|
||||
{
|
||||
|
||||
/*
|
||||
* XXX not smart about subquery references... any way to
|
||||
* do better?
|
||||
@@ -395,7 +391,6 @@ clause_selectivity(Query *root,
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* A Var at the top of a clause must be a bool Var. This
|
||||
* is equivalent to the clause reln.attribute = 't', so we
|
||||
@@ -405,7 +400,7 @@ clause_selectivity(Query *root,
|
||||
BooleanEqualOperator,
|
||||
makeList2(var,
|
||||
MAKEBOOLCONST(true,
|
||||
false)),
|
||||
false)),
|
||||
varRelid);
|
||||
}
|
||||
}
|
||||
@@ -436,7 +431,6 @@ clause_selectivity(Query *root,
|
||||
}
|
||||
else if (or_clause(clause))
|
||||
{
|
||||
|
||||
/*
|
||||
* Selectivities for an 'or' clause are computed as s1+s2 - s1*s2
|
||||
* to account for the probable overlap of selected tuple sets. XXX
|
||||
@@ -461,7 +455,6 @@ clause_selectivity(Query *root,
|
||||
|
||||
if (varRelid != 0)
|
||||
{
|
||||
|
||||
/*
|
||||
* If we are considering a nestloop join then all clauses are
|
||||
* restriction clauses, since we are only interested in the
|
||||
@@ -471,7 +464,6 @@ clause_selectivity(Query *root,
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* Otherwise, it's a join if there's more than one relation
|
||||
* used.
|
||||
@@ -482,19 +474,18 @@ clause_selectivity(Query *root,
|
||||
if (is_join_clause)
|
||||
{
|
||||
/* Estimate selectivity for a join clause. */
|
||||
s1 = join_selectivity(root, opno,
|
||||
s1 = join_selectivity(root, opno,
|
||||
((Expr *) clause)->args);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Estimate selectivity for a restriction clause. */
|
||||
s1 = restriction_selectivity(root, opno,
|
||||
((Expr *) clause)->args, varRelid);
|
||||
s1 = restriction_selectivity(root, opno,
|
||||
((Expr *) clause)->args, varRelid);
|
||||
}
|
||||
}
|
||||
else if (is_funcclause(clause))
|
||||
{
|
||||
|
||||
/*
|
||||
* This is not an operator, so we guess at the selectivity. THIS
|
||||
* IS A HACK TO GET V4 OUT THE DOOR. FUNCS SHOULD BE ABLE TO HAVE
|
||||
@@ -504,7 +495,6 @@ clause_selectivity(Query *root,
|
||||
}
|
||||
else if (is_subplan(clause))
|
||||
{
|
||||
|
||||
/*
|
||||
* Just for the moment! FIX ME! - vadim 02/04/98
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.78 2001/08/21 16:36:02 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.79 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -271,10 +271,10 @@ cost_index(Path *path, Query *root,
|
||||
*
|
||||
* When the index ordering is exactly correlated with the table ordering
|
||||
* (just after a CLUSTER, for example), the number of pages fetched should
|
||||
* be just sT. What's more, these will be sequential fetches, not the
|
||||
* random fetches that occur in the uncorrelated case. So, depending on
|
||||
* be just sT. What's more, these will be sequential fetches, not the
|
||||
* random fetches that occur in the uncorrelated case. So, depending on
|
||||
* the extent of correlation, we should estimate the actual I/O cost
|
||||
* somewhere between s * T * 1.0 and PF * random_cost. We currently
|
||||
* somewhere between s * T * 1.0 and PF * random_cost. We currently
|
||||
* interpolate linearly between these two endpoints based on the
|
||||
* correlation squared (XXX is that appropriate?).
|
||||
*
|
||||
@@ -301,7 +301,7 @@ cost_index(Path *path, Query *root,
|
||||
}
|
||||
else
|
||||
{
|
||||
double lim;
|
||||
double lim;
|
||||
|
||||
lim = (2.0 * T * b) / (2.0 * T - b);
|
||||
if (tuples_fetched <= lim)
|
||||
@@ -317,18 +317,19 @@ cost_index(Path *path, Query *root,
|
||||
}
|
||||
|
||||
/*
|
||||
* min_IO_cost corresponds to the perfectly correlated case (csquared=1),
|
||||
* max_IO_cost to the perfectly uncorrelated case (csquared=0). Note
|
||||
* that we just charge random_page_cost per page in the uncorrelated
|
||||
* case, rather than using cost_nonsequential_access, since we've already
|
||||
* accounted for caching effects by using the Mackert model.
|
||||
* min_IO_cost corresponds to the perfectly correlated case
|
||||
* (csquared=1), max_IO_cost to the perfectly uncorrelated case
|
||||
* (csquared=0). Note that we just charge random_page_cost per page
|
||||
* in the uncorrelated case, rather than using
|
||||
* cost_nonsequential_access, since we've already accounted for
|
||||
* caching effects by using the Mackert model.
|
||||
*/
|
||||
min_IO_cost = ceil(indexSelectivity * T);
|
||||
max_IO_cost = pages_fetched * random_page_cost;
|
||||
|
||||
/*
|
||||
* Now interpolate based on estimated index order correlation
|
||||
* to get total disk I/O cost for main table accesses.
|
||||
* Now interpolate based on estimated index order correlation to get
|
||||
* total disk I/O cost for main table accesses.
|
||||
*/
|
||||
csquared = indexCorrelation * indexCorrelation;
|
||||
|
||||
@@ -337,14 +338,14 @@ cost_index(Path *path, Query *root,
|
||||
/*
|
||||
* Estimate CPU costs per tuple.
|
||||
*
|
||||
* Normally the indexquals will be removed from the list of
|
||||
* restriction clauses that we have to evaluate as qpquals, so we
|
||||
* should subtract their costs from baserestrictcost. XXX For a lossy
|
||||
* index, not all the quals will be removed and so we really shouldn't
|
||||
* subtract their costs; but detecting that seems more expensive than
|
||||
* it's worth. Also, if we are doing a join then some of the indexquals
|
||||
* are join clauses and shouldn't be subtracted. Rather than work out
|
||||
* exactly how much to subtract, we don't subtract anything.
|
||||
* Normally the indexquals will be removed from the list of restriction
|
||||
* clauses that we have to evaluate as qpquals, so we should subtract
|
||||
* their costs from baserestrictcost. XXX For a lossy index, not all
|
||||
* the quals will be removed and so we really shouldn't subtract their
|
||||
* costs; but detecting that seems more expensive than it's worth.
|
||||
* Also, if we are doing a join then some of the indexquals are join
|
||||
* clauses and shouldn't be subtracted. Rather than work out exactly
|
||||
* how much to subtract, we don't subtract anything.
|
||||
*/
|
||||
cpu_per_tuple = cpu_tuple_cost + baserel->baserestrictcost;
|
||||
|
||||
@@ -501,11 +502,11 @@ cost_nestloop(Path *path, Query *root,
|
||||
|
||||
/*
|
||||
* NOTE: clearly, we must pay both outer and inner paths' startup_cost
|
||||
* before we can start returning tuples, so the join's startup cost
|
||||
* is their sum. What's not so clear is whether the inner path's
|
||||
* before we can start returning tuples, so the join's startup cost is
|
||||
* their sum. What's not so clear is whether the inner path's
|
||||
* startup_cost must be paid again on each rescan of the inner path.
|
||||
* This is not true if the inner path is materialized, but probably
|
||||
* is true otherwise. Since we don't yet have clean handling of the
|
||||
* This is not true if the inner path is materialized, but probably is
|
||||
* true otherwise. Since we don't yet have clean handling of the
|
||||
* decision whether to materialize a path, we can't tell here which
|
||||
* will happen. As a compromise, charge 50% of the inner startup cost
|
||||
* for each restart.
|
||||
@@ -615,9 +616,9 @@ cost_mergejoin(Path *path, Query *root,
|
||||
/*
|
||||
* The number of tuple comparisons needed depends drastically on the
|
||||
* number of equal keys in the two source relations, which we have no
|
||||
* good way of estimating. Somewhat arbitrarily, we charge one
|
||||
* tuple comparison (one cpu_operator_cost) for each tuple in the
|
||||
* two source relations. This is probably a lower bound.
|
||||
* good way of estimating. Somewhat arbitrarily, we charge one tuple
|
||||
* comparison (one cpu_operator_cost) for each tuple in the two source
|
||||
* relations. This is probably a lower bound.
|
||||
*/
|
||||
run_cost += cpu_operator_cost *
|
||||
(outer_path->parent->rows + inner_path->parent->rows);
|
||||
@@ -625,7 +626,7 @@ cost_mergejoin(Path *path, Query *root,
|
||||
/*
|
||||
* For each tuple that gets through the mergejoin proper, we charge
|
||||
* cpu_tuple_cost plus the cost of evaluating additional restriction
|
||||
* clauses that are to be applied at the join. It's OK to use an
|
||||
* clauses that are to be applied at the join. It's OK to use an
|
||||
* approximate selectivity here, since in most cases this is a minor
|
||||
* component of the cost.
|
||||
*/
|
||||
@@ -685,8 +686,8 @@ cost_hashjoin(Path *path, Query *root,
|
||||
run_cost += cpu_operator_cost * outer_path->parent->rows;
|
||||
|
||||
/*
|
||||
* Determine bucketsize fraction for inner relation. First we have
|
||||
* to figure out which side of the hashjoin clause is the inner side.
|
||||
* Determine bucketsize fraction for inner relation. First we have to
|
||||
* figure out which side of the hashjoin clause is the inner side.
|
||||
*/
|
||||
Assert(length(hashclauses) == 1);
|
||||
Assert(IsA(lfirst(hashclauses), RestrictInfo));
|
||||
@@ -696,9 +697,9 @@ cost_hashjoin(Path *path, Query *root,
|
||||
right = get_rightop(restrictinfo->clause);
|
||||
|
||||
/*
|
||||
* Since we tend to visit the same clauses over and over when
|
||||
* planning a large query, we cache the bucketsize estimate in
|
||||
* the RestrictInfo node to avoid repeated lookups of statistics.
|
||||
* Since we tend to visit the same clauses over and over when planning
|
||||
* a large query, we cache the bucketsize estimate in the RestrictInfo
|
||||
* node to avoid repeated lookups of statistics.
|
||||
*/
|
||||
if (intMember(right->varno, inner_path->parent->relids))
|
||||
{
|
||||
@@ -726,9 +727,9 @@ cost_hashjoin(Path *path, Query *root,
|
||||
|
||||
/*
|
||||
* The number of tuple comparisons needed is the number of outer
|
||||
* tuples times the typical number of tuples in a hash bucket,
|
||||
* which is the inner relation size times its bucketsize fraction.
|
||||
* We charge one cpu_operator_cost per tuple comparison.
|
||||
* tuples times the typical number of tuples in a hash bucket, which
|
||||
* is the inner relation size times its bucketsize fraction. We charge
|
||||
* one cpu_operator_cost per tuple comparison.
|
||||
*/
|
||||
run_cost += cpu_operator_cost * outer_path->parent->rows *
|
||||
ceil(inner_path->parent->rows * innerbucketsize);
|
||||
@@ -736,7 +737,7 @@ cost_hashjoin(Path *path, Query *root,
|
||||
/*
|
||||
* For each tuple that gets through the hashjoin proper, we charge
|
||||
* cpu_tuple_cost plus the cost of evaluating additional restriction
|
||||
* clauses that are to be applied at the join. It's OK to use an
|
||||
* clauses that are to be applied at the join. It's OK to use an
|
||||
* approximate selectivity here, since in most cases this is a minor
|
||||
* component of the cost.
|
||||
*/
|
||||
@@ -792,11 +793,11 @@ cost_hashjoin(Path *path, Query *root,
|
||||
* distribution, so this will have to do for now.
|
||||
*
|
||||
* We can get the number of buckets the executor will use for the given
|
||||
* input relation. If the data were perfectly distributed, with the same
|
||||
* input relation. If the data were perfectly distributed, with the same
|
||||
* number of tuples going into each available bucket, then the bucketsize
|
||||
* fraction would be 1/nbuckets. But this happy state of affairs will occur
|
||||
* only if (a) there are at least nbuckets distinct data values, and (b)
|
||||
* we have a not-too-skewed data distribution. Otherwise the buckets will
|
||||
* we have a not-too-skewed data distribution. Otherwise the buckets will
|
||||
* be nonuniformly occupied. If the other relation in the join has a key
|
||||
* distribution similar to this one's, then the most-loaded buckets are
|
||||
* exactly those that will be probed most often. Therefore, the "average"
|
||||
@@ -828,8 +829,8 @@ estimate_hash_bucketsize(Query *root, Var *var)
|
||||
int nnumbers;
|
||||
|
||||
/*
|
||||
* Lookup info about var's relation and attribute;
|
||||
* if none available, return default estimate.
|
||||
* Lookup info about var's relation and attribute; if none available,
|
||||
* return default estimate.
|
||||
*/
|
||||
if (!IsA(var, Var))
|
||||
return 0.1;
|
||||
@@ -891,12 +892,13 @@ estimate_hash_bucketsize(Query *root, Var *var)
|
||||
avgfreq = (1.0 - stats->stanullfrac) / ndistinct;
|
||||
|
||||
/*
|
||||
* Adjust ndistinct to account for restriction clauses. Observe we are
|
||||
* assuming that the data distribution is affected uniformly by the
|
||||
* restriction clauses!
|
||||
* Adjust ndistinct to account for restriction clauses. Observe we
|
||||
* are assuming that the data distribution is affected uniformly by
|
||||
* the restriction clauses!
|
||||
*
|
||||
* XXX Possibly better way, but much more expensive: multiply by
|
||||
* selectivity of rel's restriction clauses that mention the target Var.
|
||||
* selectivity of rel's restriction clauses that mention the target
|
||||
* Var.
|
||||
*/
|
||||
ndistinct *= rel->rows / rel->tuples;
|
||||
|
||||
@@ -929,7 +931,8 @@ estimate_hash_bucketsize(Query *root, Var *var)
|
||||
}
|
||||
|
||||
/*
|
||||
* Adjust estimated bucketsize upward to account for skewed distribution.
|
||||
* Adjust estimated bucketsize upward to account for skewed
|
||||
* distribution.
|
||||
*/
|
||||
if (avgfreq > 0.0 && mcvfreq > avgfreq)
|
||||
estfract *= mcvfreq / avgfreq;
|
||||
@@ -1084,19 +1087,20 @@ cost_qual_eval_walker(Node *node, Cost *total)
|
||||
static Selectivity
|
||||
approx_selectivity(Query *root, List *quals)
|
||||
{
|
||||
Selectivity total = 1.0;
|
||||
Selectivity total = 1.0;
|
||||
List *l;
|
||||
|
||||
foreach(l, quals)
|
||||
{
|
||||
Node *qual = (Node *) lfirst(l);
|
||||
Selectivity selec;
|
||||
Selectivity selec;
|
||||
|
||||
/*
|
||||
* RestrictInfo nodes contain a this_selec field reserved for this
|
||||
* routine's use, so that it's not necessary to evaluate the qual
|
||||
* clause's selectivity more than once. If the clause's selectivity
|
||||
* hasn't been computed yet, the field will contain -1.
|
||||
* clause's selectivity more than once. If the clause's
|
||||
* selectivity hasn't been computed yet, the field will contain
|
||||
* -1.
|
||||
*/
|
||||
if (qual && IsA(qual, RestrictInfo))
|
||||
{
|
||||
@@ -1254,7 +1258,7 @@ set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
|
||||
* NB: this works best on base relations because it prefers to look at
|
||||
* real Vars. It will fail to make use of pg_statistic info when applied
|
||||
* to a subquery relation, even if the subquery outputs are simple vars
|
||||
* that we could have gotten info for. Is it worth trying to be smarter
|
||||
* that we could have gotten info for. Is it worth trying to be smarter
|
||||
* about subqueries?
|
||||
*/
|
||||
static void
|
||||
@@ -1266,15 +1270,15 @@ set_rel_width(Query *root, RelOptInfo *rel)
|
||||
foreach(tllist, rel->targetlist)
|
||||
{
|
||||
TargetEntry *tle = (TargetEntry *) lfirst(tllist);
|
||||
int32 item_width;
|
||||
int32 item_width;
|
||||
|
||||
/*
|
||||
* If it's a Var, try to get statistical info from pg_statistic.
|
||||
*/
|
||||
if (tle->expr && IsA(tle->expr, Var))
|
||||
{
|
||||
Var *var = (Var *) tle->expr;
|
||||
Oid relid;
|
||||
Var *var = (Var *) tle->expr;
|
||||
Oid relid;
|
||||
|
||||
relid = getrelid(var->varno, root->rtable);
|
||||
if (relid != InvalidOid)
|
||||
@@ -1287,6 +1291,7 @@ set_rel_width(Query *root, RelOptInfo *rel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Not a Var, or can't find statistics for it. Estimate using
|
||||
* just the type info.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.111 2001/08/21 16:36:02 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.112 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -288,7 +288,6 @@ match_index_orclauses(RelOptInfo *rel,
|
||||
|
||||
if (restriction_is_or_clause(restrictinfo))
|
||||
{
|
||||
|
||||
/*
|
||||
* Add this index to the subclause index list for each
|
||||
* subclause that it matches.
|
||||
@@ -444,9 +443,10 @@ extract_or_indexqual_conditions(RelOptInfo *rel,
|
||||
Oid *classes = index->classlist;
|
||||
|
||||
/*
|
||||
* Extract relevant indexclauses in indexkey order. This is essentially
|
||||
* just like group_clauses_by_indexkey() except that the input and
|
||||
* output are lists of bare clauses, not of RestrictInfo nodes.
|
||||
* Extract relevant indexclauses in indexkey order. This is
|
||||
* essentially just like group_clauses_by_indexkey() except that the
|
||||
* input and output are lists of bare clauses, not of RestrictInfo
|
||||
* nodes.
|
||||
*/
|
||||
do
|
||||
{
|
||||
@@ -459,7 +459,7 @@ extract_or_indexqual_conditions(RelOptInfo *rel,
|
||||
{
|
||||
foreach(item, orsubclause->args)
|
||||
{
|
||||
Expr *subsubclause = (Expr *) lfirst(item);
|
||||
Expr *subsubclause = (Expr *) lfirst(item);
|
||||
|
||||
if (match_clause_to_indexkey(rel, index,
|
||||
curIndxKey, curClass,
|
||||
@@ -470,9 +470,7 @@ extract_or_indexqual_conditions(RelOptInfo *rel,
|
||||
else if (match_clause_to_indexkey(rel, index,
|
||||
curIndxKey, curClass,
|
||||
orsubclause, false))
|
||||
{
|
||||
clausegroup = makeList1(orsubclause);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we found no clauses for this indexkey in the OR subclause
|
||||
@@ -492,8 +490,8 @@ extract_or_indexqual_conditions(RelOptInfo *rel,
|
||||
}
|
||||
|
||||
/*
|
||||
* If still no clauses match this key, we're done; we don't want to
|
||||
* look at keys to its right.
|
||||
* If still no clauses match this key, we're done; we don't want
|
||||
* to look at keys to its right.
|
||||
*/
|
||||
if (clausegroup == NIL)
|
||||
break;
|
||||
@@ -744,7 +742,6 @@ match_clause_to_indexkey(RelOptInfo *rel,
|
||||
|
||||
if (!join)
|
||||
{
|
||||
|
||||
/*
|
||||
* Not considering joins, so check for clauses of the form:
|
||||
* (indexkey operator constant) or (constant operator indexkey).
|
||||
@@ -782,7 +779,6 @@ match_clause_to_indexkey(RelOptInfo *rel,
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* Check for an indexqual that could be handled by a nestloop
|
||||
* join. We need the index key to be compared against an
|
||||
@@ -921,7 +917,6 @@ indexable_operator(Expr *clause, Oid opclass, bool indexkey_on_left)
|
||||
{
|
||||
if (new_op != expr_op)
|
||||
{
|
||||
|
||||
/*
|
||||
* OK, we found a binary-compatible operator of the same name;
|
||||
* now does it match the index?
|
||||
@@ -1144,7 +1139,7 @@ static const StrategyNumber
|
||||
* and a "simple clause" restriction.
|
||||
*
|
||||
* We have two strategies for determining whether one simple clause
|
||||
* implies another. A simple and general way is to see if they are
|
||||
* implies another. A simple and general way is to see if they are
|
||||
* equal(); this works for any kind of expression. (Actually, there
|
||||
* is an implied assumption that the functions in the expression are
|
||||
* cachable, ie dependent only on their input arguments --- but this
|
||||
@@ -1187,8 +1182,8 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
|
||||
return true;
|
||||
|
||||
/*
|
||||
* Can't do anything more unless they are both binary opclauses with
|
||||
* a Var on the left and a Const on the right.
|
||||
* Can't do anything more unless they are both binary opclauses with a
|
||||
* Var on the left and a Const on the right.
|
||||
*/
|
||||
if (!is_opclause((Node *) predicate))
|
||||
return false;
|
||||
@@ -1223,8 +1218,8 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
|
||||
/*
|
||||
* 1. Find a "btree" strategy number for the pred_op
|
||||
*
|
||||
* The following assumes that any given operator will only be in a
|
||||
* single btree operator class. This is true at least for all the
|
||||
* The following assumes that any given operator will only be in a single
|
||||
* btree operator class. This is true at least for all the
|
||||
* pre-defined operator classes. If it isn't true, then whichever
|
||||
* operator class happens to be returned first for the given operator
|
||||
* will be used to find the associated strategy numbers for the test.
|
||||
@@ -1237,7 +1232,7 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
|
||||
|
||||
relation = heap_openr(AccessMethodOperatorRelationName, AccessShareLock);
|
||||
scan = heap_beginscan(relation, false, SnapshotNow, 1, entry);
|
||||
|
||||
|
||||
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
|
||||
{
|
||||
aform = (Form_pg_amop) GETSTRUCT(tuple);
|
||||
@@ -1246,7 +1241,11 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
|
||||
/* Get the predicate operator's btree strategy number (1 to 5) */
|
||||
pred_strategy = (StrategyNumber) aform->amopstrategy;
|
||||
Assert(pred_strategy >= 1 && pred_strategy <= 5);
|
||||
/* Remember which operator class this strategy number came from */
|
||||
|
||||
/*
|
||||
* Remember which operator class this strategy number came
|
||||
* from
|
||||
*/
|
||||
opclass_id = aform->amopclaid;
|
||||
break;
|
||||
}
|
||||
@@ -1457,8 +1456,8 @@ index_innerjoin(Query *root, RelOptInfo *rel, IndexOptInfo *index,
|
||||
|
||||
/*
|
||||
* Note that we are making a pathnode for a single-scan indexscan;
|
||||
* therefore, both indexinfo and indexqual should be single-element
|
||||
* lists.
|
||||
* therefore, both indexinfo and indexqual should be
|
||||
* single-element lists.
|
||||
*/
|
||||
pathnode->indexinfo = makeList1(index);
|
||||
pathnode->indexqual = makeList1(indexquals);
|
||||
@@ -1516,7 +1515,6 @@ match_index_to_operand(int indexkey,
|
||||
RelOptInfo *rel,
|
||||
IndexOptInfo *index)
|
||||
{
|
||||
|
||||
/*
|
||||
* Ignore any RelabelType node above the indexkey. This is needed to
|
||||
* be able to apply indexscanning in binary-compatible-operator cases.
|
||||
@@ -1528,7 +1526,6 @@ match_index_to_operand(int indexkey,
|
||||
|
||||
if (index->indproc == InvalidOid)
|
||||
{
|
||||
|
||||
/*
|
||||
* Simple index.
|
||||
*/
|
||||
@@ -1860,7 +1857,6 @@ expand_indexqual_conditions(List *indexquals)
|
||||
|
||||
switch (expr_op)
|
||||
{
|
||||
|
||||
/*
|
||||
* LIKE and regex operators are not members of any index
|
||||
* opclass, so if we find one in an indexqual list we can
|
||||
@@ -2065,17 +2061,17 @@ prefix_quals(Var *leftop, Oid expr_op,
|
||||
/*
|
||||
* Given a leftop and a rightop, and a inet-class sup/sub operator,
|
||||
* generate suitable indexqual condition(s). expr_op is the original
|
||||
* operator.
|
||||
* operator.
|
||||
*/
|
||||
static List *
|
||||
network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop)
|
||||
{
|
||||
bool is_eq;
|
||||
char *opr1name;
|
||||
Datum opr1right;
|
||||
Datum opr2right;
|
||||
Oid opr1oid;
|
||||
Oid opr2oid;
|
||||
bool is_eq;
|
||||
char *opr1name;
|
||||
Datum opr1right;
|
||||
Datum opr2right;
|
||||
Oid opr1oid;
|
||||
Oid opr2oid;
|
||||
List *result;
|
||||
Oid datatype;
|
||||
Oper *op;
|
||||
@@ -2084,30 +2080,30 @@ network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop)
|
||||
switch (expr_op)
|
||||
{
|
||||
case OID_INET_SUB_OP:
|
||||
datatype = INETOID;
|
||||
is_eq = false;
|
||||
datatype = INETOID;
|
||||
is_eq = false;
|
||||
break;
|
||||
case OID_INET_SUBEQ_OP:
|
||||
datatype = INETOID;
|
||||
is_eq = true;
|
||||
datatype = INETOID;
|
||||
is_eq = true;
|
||||
break;
|
||||
case OID_CIDR_SUB_OP:
|
||||
datatype = CIDROID;
|
||||
is_eq = false;
|
||||
datatype = CIDROID;
|
||||
is_eq = false;
|
||||
break;
|
||||
case OID_CIDR_SUBEQ_OP:
|
||||
datatype = CIDROID;
|
||||
is_eq = true;
|
||||
datatype = CIDROID;
|
||||
is_eq = true;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "network_prefix_quals: unexpected operator %u",
|
||||
expr_op);
|
||||
return NIL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* create clause "key >= network_scan_first( rightop )", or ">"
|
||||
* if the operator disallows equality.
|
||||
* create clause "key >= network_scan_first( rightop )", or ">" if the
|
||||
* operator disallows equality.
|
||||
*/
|
||||
|
||||
opr1name = is_eq ? ">=" : ">";
|
||||
@@ -2116,11 +2112,11 @@ network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop)
|
||||
elog(ERROR, "network_prefix_quals: no %s operator for type %u",
|
||||
opr1name, datatype);
|
||||
|
||||
opr1right = network_scan_first( rightop );
|
||||
opr1right = network_scan_first(rightop);
|
||||
|
||||
op = makeOper(opr1oid, InvalidOid, BOOLOID);
|
||||
expr = make_opclause(op, leftop,
|
||||
(Var *) makeConst(datatype, -1, opr1right,
|
||||
expr = make_opclause(op, leftop,
|
||||
(Var *) makeConst(datatype, -1, opr1right,
|
||||
false, false, false, false));
|
||||
result = makeList1(expr);
|
||||
|
||||
@@ -2131,11 +2127,11 @@ network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop)
|
||||
elog(ERROR, "network_prefix_quals: no <= operator for type %u",
|
||||
datatype);
|
||||
|
||||
opr2right = network_scan_last( rightop );
|
||||
opr2right = network_scan_last(rightop);
|
||||
|
||||
op = makeOper(opr2oid, InvalidOid, BOOLOID);
|
||||
expr = make_opclause(op, leftop,
|
||||
(Var *) makeConst(datatype, -1, opr2right,
|
||||
expr = make_opclause(op, leftop,
|
||||
(Var *) makeConst(datatype, -1, opr2right,
|
||||
false, false, false, false));
|
||||
result = lappend(result, expr);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.65 2001/06/05 05:26:04 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.66 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,6 @@ static void match_unsorted_inner(Query *root, RelOptInfo *joinrel,
|
||||
RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||
List *restrictlist, List *mergeclause_list,
|
||||
JoinType jointype);
|
||||
|
||||
#endif
|
||||
static void hash_inner_and_outer(Query *root, RelOptInfo *joinrel,
|
||||
RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||
@@ -297,9 +296,9 @@ match_unsorted_outer(Query *root,
|
||||
/*
|
||||
* Nestloop only supports inner and left joins. Also, if we are doing
|
||||
* a right or full join, we must use *all* the mergeclauses as join
|
||||
* clauses, else we will not have a valid plan. (Although these two flags
|
||||
* are currently inverses, keep them separate for clarity and possible
|
||||
* future changes.)
|
||||
* clauses, else we will not have a valid plan. (Although these two
|
||||
* flags are currently inverses, keep them separate for clarity and
|
||||
* possible future changes.)
|
||||
*/
|
||||
switch (jointype)
|
||||
{
|
||||
@@ -316,7 +315,7 @@ match_unsorted_outer(Query *root,
|
||||
default:
|
||||
elog(ERROR, "match_unsorted_outer: unexpected join type %d",
|
||||
(int) jointype);
|
||||
nestjoinOK = false; /* keep compiler quiet */
|
||||
nestjoinOK = false; /* keep compiler quiet */
|
||||
useallclauses = false;
|
||||
break;
|
||||
}
|
||||
@@ -350,12 +349,11 @@ match_unsorted_outer(Query *root,
|
||||
|
||||
if (nestjoinOK)
|
||||
{
|
||||
|
||||
/*
|
||||
* Always consider a nestloop join with this outer and
|
||||
* cheapest-total-cost inner. Consider nestloops using the
|
||||
* cheapest-startup-cost inner as well, and the best
|
||||
* innerjoin indexpath.
|
||||
* cheapest-startup-cost inner as well, and the best innerjoin
|
||||
* indexpath.
|
||||
*/
|
||||
add_path(joinrel, (Path *)
|
||||
create_nestloop_path(root,
|
||||
@@ -494,7 +492,6 @@ match_unsorted_outer(Query *root,
|
||||
/* Found a cheap (or even-cheaper) sorted path */
|
||||
if (innerpath != cheapest_total_inner)
|
||||
{
|
||||
|
||||
/*
|
||||
* Avoid rebuilding clause list if we already made
|
||||
* one; saves memory in big join trees...
|
||||
@@ -526,6 +523,7 @@ match_unsorted_outer(Query *root,
|
||||
}
|
||||
cheapest_startup_inner = innerpath;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't consider truncated sortkeys if we need all clauses.
|
||||
*/
|
||||
@@ -576,7 +574,7 @@ match_unsorted_inner(Query *root,
|
||||
default:
|
||||
elog(ERROR, "match_unsorted_inner: unexpected join type %d",
|
||||
(int) jointype);
|
||||
useallclauses = false; /* keep compiler quiet */
|
||||
useallclauses = false; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -673,7 +671,6 @@ match_unsorted_inner(Query *root,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.54 2001/10/18 16:11:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.55 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -69,7 +69,6 @@ make_rels_by_joins(Query *root, int level, List **joinrels)
|
||||
|
||||
if (old_rel->joininfo != NIL)
|
||||
{
|
||||
|
||||
/*
|
||||
* Note that if all available join clauses for this rel
|
||||
* require more than one other rel, we will fail to make any
|
||||
@@ -84,7 +83,6 @@ make_rels_by_joins(Query *root, int level, List **joinrels)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* Oops, we have a relation that is not joined to any other
|
||||
* relation. Cartesian product time.
|
||||
@@ -195,7 +193,6 @@ make_rels_by_joins(Query *root, int level, List **joinrels)
|
||||
*/
|
||||
if (result_rels == NIL)
|
||||
{
|
||||
|
||||
/*
|
||||
* This loop is just like the first one, except we always call
|
||||
* make_rels_by_clauseless_joins().
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.44 2001/06/05 17:13:52 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.45 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -175,7 +175,7 @@ best_or_subclause_indices(Query *root,
|
||||
|
||||
pathnode->indexinfo = lappend(pathnode->indexinfo, best_indexinfo);
|
||||
pathnode->indexqual = lappend(pathnode->indexqual, best_indexqual);
|
||||
if (slist == subclauses) /* first scan? */
|
||||
if (slist == subclauses)/* first scan? */
|
||||
pathnode->path.startup_cost = best_startup_cost;
|
||||
pathnode->path.total_cost += best_total_cost;
|
||||
|
||||
@@ -202,7 +202,7 @@ best_or_subclause_index(Query *root,
|
||||
RelOptInfo *rel,
|
||||
Expr *subclause,
|
||||
List *indices,
|
||||
IndexOptInfo **retIndexInfo, /* return value */
|
||||
IndexOptInfo **retIndexInfo, /* return value */
|
||||
List **retIndexQual, /* return value */
|
||||
Cost *retStartupCost, /* return value */
|
||||
Cost *retTotalCost) /* return value */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.33 2001/10/18 16:11:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.34 2001/10/25 05:49:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -109,7 +109,6 @@ add_equijoined_keys(Query *root, RestrictInfo *restrictinfo)
|
||||
|
||||
if (item1here || item2here)
|
||||
{
|
||||
|
||||
/*
|
||||
* If find both in same equivalence set, no need to do any
|
||||
* more
|
||||
@@ -318,7 +317,7 @@ compare_pathkeys(List *keys1, List *keys2)
|
||||
if (key1 == NIL && key2 == NIL)
|
||||
return PATHKEYS_EQUAL;
|
||||
if (key1 != NIL)
|
||||
return PATHKEYS_BETTER1;/* key1 is longer */
|
||||
return PATHKEYS_BETTER1; /* key1 is longer */
|
||||
return PATHKEYS_BETTER2; /* key2 is longer */
|
||||
}
|
||||
|
||||
@@ -368,7 +367,7 @@ compare_noncanonical_pathkeys(List *keys1, List *keys2)
|
||||
if (key1 == NIL && key2 == NIL)
|
||||
return PATHKEYS_EQUAL;
|
||||
if (key1 != NIL)
|
||||
return PATHKEYS_BETTER1;/* key1 is longer */
|
||||
return PATHKEYS_BETTER1; /* key1 is longer */
|
||||
return PATHKEYS_BETTER2; /* key2 is longer */
|
||||
}
|
||||
|
||||
@@ -382,8 +381,8 @@ pathkeys_contained_in(List *keys1, List *keys2)
|
||||
{
|
||||
switch (compare_pathkeys(keys1, keys2))
|
||||
{
|
||||
case PATHKEYS_EQUAL:
|
||||
case PATHKEYS_BETTER2:
|
||||
case PATHKEYS_EQUAL:
|
||||
case PATHKEYS_BETTER2:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
@@ -400,8 +399,8 @@ noncanonical_pathkeys_contained_in(List *keys1, List *keys2)
|
||||
{
|
||||
switch (compare_noncanonical_pathkeys(keys1, keys2))
|
||||
{
|
||||
case PATHKEYS_EQUAL:
|
||||
case PATHKEYS_BETTER2:
|
||||
case PATHKEYS_EQUAL:
|
||||
case PATHKEYS_BETTER2:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
@@ -632,7 +631,6 @@ build_join_pathkeys(Query *root,
|
||||
RelOptInfo *joinrel,
|
||||
List *outer_pathkeys)
|
||||
{
|
||||
|
||||
/*
|
||||
* This used to be quite a complex bit of code, but now that all
|
||||
* pathkey sublists start out life canonicalized, we don't have to do
|
||||
|
||||
Reference in New Issue
Block a user