Commit d3f0e87d authored by Bruce Momjian's avatar Bruce Momjian

Cost cleanup.

parent 6b00ec37
...@@ -52,7 +52,7 @@ planner() ...@@ -52,7 +52,7 @@ planner()
if a join from the join clause adds only one relation, do the join if a join from the join clause adds only one relation, do the join
or find_clauseless_joins() or find_clauseless_joins()
find_all_join_paths() find_all_join_paths()
generate paths(nested,mergesort) for joins found in find_join_rels() generate paths(nested,sortmerge) for joins found in find_join_rels()
prune_joinrels() prune_joinrels()
remove from the join list the relation we just added to each join remove from the join list the relation we just added to each join
prune_rel_paths() prune_rel_paths()
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.17 1997/12/18 03:03:35 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.18 1997/12/18 12:20:30 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -46,44 +46,33 @@ ...@@ -46,44 +46,33 @@
static List *switch_outer(List *clauses); static List *switch_outer(List *clauses);
static Scan *create_scan_node(Path *best_path, List *tlist); static Scan *create_scan_node(Path *best_path, List *tlist);
static Join *create_join_node(JoinPath *best_path, List *tlist); static Join *create_join_node(JoinPath *best_path, List *tlist);
static SeqScan * static SeqScan *create_seqscan_node(Path *best_path, List *tlist,
create_seqscan_node(Path *best_path, List *tlist,
List *scan_clauses); List *scan_clauses);
static IndexScan * static IndexScan *create_indexscan_node(IndexPath *best_path, List *tlist,
create_indexscan_node(IndexPath *best_path, List *tlist,
List *scan_clauses); List *scan_clauses);
static NestLoop * static NestLoop *create_nestloop_node(JoinPath *best_path, List *tlist,
create_nestloop_node(JoinPath *best_path, List *tlist,
List *clauses, Plan *outer_node, List *outer_tlist, List *clauses, Plan *outer_node, List *outer_tlist,
Plan *inner_node, List *inner_tlist); Plan *inner_node, List *inner_tlist);
static MergeJoin * static MergeJoin *create_mergejoin_node(MergePath *best_path, List *tlist,
create_mergejoin_node(MergePath *best_path, List *tlist,
List *clauses, Plan *outer_node, List *outer_tlist, List *clauses, Plan *outer_node, List *outer_tlist,
Plan *inner_node, List *inner_tlist); Plan *inner_node, List *inner_tlist);
static HashJoin * static HashJoin *create_hashjoin_node(HashPath *best_path, List *tlist,
create_hashjoin_node(HashPath *best_path, List *tlist,
List *clauses, Plan *outer_node, List *outer_tlist, List *clauses, Plan *outer_node, List *outer_tlist,
Plan *inner_node, List *inner_tlist); Plan *inner_node, List *inner_tlist);
static Node *fix_indxqual_references(Node *clause, Path *index_path); static Node *fix_indxqual_references(Node *clause, Path *index_path);
static Temp * static Temp *make_temp(List *tlist, List *keys, Oid *operators,
make_temp(List *tlist, List *keys, Oid *operators,
Plan *plan_node, int temptype); Plan *plan_node, int temptype);
static IndexScan * static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid,
make_indexscan(List *qptlist, List *qpqual, Index scanrelid, List *indxid, List *indxqual, Cost cost);
List *indxid, List *indxqual); static NestLoop *make_nestloop(List *qptlist, List *qpqual, Plan *lefttree,
static NestLoop *
make_nestloop(List *qptlist, List *qpqual, Plan *lefttree,
Plan *righttree); Plan *righttree);
static HashJoin * static HashJoin *make_hashjoin(List *tlist, List *qpqual,
make_hashjoin(List *tlist, List *qpqual,
List *hashclauses, Plan *lefttree, Plan *righttree); List *hashclauses, Plan *lefttree, Plan *righttree);
static Hash *make_hash(List *tlist, Var *hashkey, Plan *lefttree); static Hash *make_hash(List *tlist, Var *hashkey, Plan *lefttree);
static MergeJoin * static MergeJoin *make_mergesort(List *tlist, List *qpqual,
make_mergesort(List *tlist, List *qpqual,
List *mergeclauses, Oid opcode, Oid *rightorder, List *mergeclauses, Oid opcode, Oid *rightorder,
Oid *leftorder, Plan *righttree, Plan *lefttree); Oid *leftorder, Plan *righttree, Plan *lefttree);
static Material * static Material *make_material(List *tlist, Oid tempid, Plan *lefttree,
make_material(List *tlist, Oid tempid, Plan *lefttree,
int keycount); int keycount);
/* /*
...@@ -415,9 +404,8 @@ create_indexscan_node(IndexPath *best_path, ...@@ -415,9 +404,8 @@ create_indexscan_node(IndexPath *best_path,
qpqual, qpqual,
lfirsti(best_path->path.parent->relids), lfirsti(best_path->path.parent->relids),
best_path->indexid, best_path->indexid,
fixed_indxqual); fixed_indxqual,
best_path->path.path_cost);
scan_node->scan.plan.cost = best_path->path.path_cost;
return (scan_node); return (scan_node);
} }
...@@ -960,12 +948,13 @@ make_indexscan(List *qptlist, ...@@ -960,12 +948,13 @@ make_indexscan(List *qptlist,
List *qpqual, List *qpqual,
Index scanrelid, Index scanrelid,
List *indxid, List *indxid,
List *indxqual) List *indxqual,
Cost cost)
{ {
IndexScan *node = makeNode(IndexScan); IndexScan *node = makeNode(IndexScan);
Plan *plan = &node->scan.plan; Plan *plan = &node->scan.plan;
plan->cost = 0.0; plan->cost = cost;
plan->state = (EState *) NULL; plan->state = (EState *) NULL;
plan->targetlist = qptlist; plan->targetlist = qptlist;
plan->qual = qpqual; plan->qual = qpqual;
...@@ -1117,11 +1106,11 @@ make_material(List *tlist, ...@@ -1117,11 +1106,11 @@ make_material(List *tlist,
} }
Agg * Agg *
make_agg(List *tlist, int nagg, Aggreg **aggs) make_agg(List *tlist, int nagg, Aggreg **aggs, Plan *lefttree)
{ {
Agg *node = makeNode(Agg); Agg *node = makeNode(Agg);
node->plan.cost = 0.0; node->plan.cost = (lefttree ? lefttree->cost : 0);
node->plan.state = (EState *) NULL; node->plan.state = (EState *) NULL;
node->plan.qual = NULL; node->plan.qual = NULL;
node->plan.targetlist = tlist; node->plan.targetlist = tlist;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: planmain.h,v 1.6 1997/11/26 01:13:48 momjian Exp $ * $Id: planmain.h,v 1.7 1997/12/18 12:21:02 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
/* /*
* prototypes for plan/planmain.c * prototypes for plan/planmain.c
*/ */
extern Plan * extern Plan *query_planner(Query *root,
query_planner(Query *root,
int command_type, List *tlist, List *qual); int command_type, List *tlist, List *qual);
...@@ -30,15 +29,12 @@ query_planner(Query *root, ...@@ -30,15 +29,12 @@ query_planner(Query *root,
* prototypes for plan/createplan.c * prototypes for plan/createplan.c
*/ */
extern Plan *create_plan(Path *best_path); extern Plan *create_plan(Path *best_path);
extern SeqScan * extern SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid,
make_seqscan(List *qptlist, List *qpqual, Index scanrelid,
Plan *lefttree); Plan *lefttree);
extern Sort * extern Sort *make_sort(List *tlist, Oid tempid, Plan *lefttree,
make_sort(List *tlist, Oid tempid, Plan *lefttree,
int keycount); int keycount);
extern Agg *make_agg(List *tlist, int nagg, Aggreg **aggs); extern Agg *make_agg(List *tlist, int nagg, Aggreg **aggs, Plan *lefttree);
extern Group * extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp,
make_group(List *tlist, bool tuplePerGroup, int ngrp,
AttrNumber *grpColIdx, Sort *lefttree); AttrNumber *grpColIdx, Sort *lefttree);
extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr); extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr);
extern List *generate_fjoin(List *tlist); extern List *generate_fjoin(List *tlist);
...@@ -56,11 +52,9 @@ extern void add_missing_vars_to_base_rels(Query *root, List *tlist); ...@@ -56,11 +52,9 @@ extern void add_missing_vars_to_base_rels(Query *root, List *tlist);
* prototypes for plan/setrefs.c * prototypes for plan/setrefs.c
*/ */
extern void set_tlist_references(Plan *plan); extern void set_tlist_references(Plan *plan);
extern List * extern List *join_references(List *clauses, List *outer_tlist,
join_references(List *clauses, List *outer_tlist,
List *inner_tlist); List *inner_tlist);
extern List * extern List *index_outerjoin_references(List *inner_indxqual,
index_outerjoin_references(List *inner_indxqual,
List *outer_tlist, Index inner_relid); List *outer_tlist, Index inner_relid);
extern void set_result_tlist_references(Result *resultNode); extern void set_result_tlist_references(Result *resultNode);
extern void set_agg_tlist_references(Agg *aggNode); extern void set_agg_tlist_references(Agg *aggNode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment