diff --git a/src/backend/optimizer/README b/src/backend/optimizer/README index d9ced5d5396c6969937a440edb37d5310241d4df..f9a2cb982fcf88369b74e06c84f4c75477f3ac4f 100644 --- a/src/backend/optimizer/README +++ b/src/backend/optimizer/README @@ -52,7 +52,7 @@ planner() if a join from the join clause adds only one relation, do the join or find_clauseless_joins() 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() remove from the join list the relation we just added to each join prune_rel_paths() diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 2be872f9302694abcf022f502264b65bd89e5f5d..54125052fa36c30bacb9d96e0310db57497cb089 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -7,7 +7,7 @@ * * * 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 @@ static List *switch_outer(List *clauses); static Scan *create_scan_node(Path *best_path, List *tlist); static Join *create_join_node(JoinPath *best_path, List *tlist); -static SeqScan * -create_seqscan_node(Path *best_path, List *tlist, +static SeqScan *create_seqscan_node(Path *best_path, List *tlist, List *scan_clauses); -static IndexScan * -create_indexscan_node(IndexPath *best_path, List *tlist, +static IndexScan *create_indexscan_node(IndexPath *best_path, List *tlist, List *scan_clauses); -static NestLoop * -create_nestloop_node(JoinPath *best_path, List *tlist, +static NestLoop *create_nestloop_node(JoinPath *best_path, List *tlist, List *clauses, Plan *outer_node, List *outer_tlist, Plan *inner_node, List *inner_tlist); -static MergeJoin * -create_mergejoin_node(MergePath *best_path, List *tlist, +static MergeJoin *create_mergejoin_node(MergePath *best_path, List *tlist, List *clauses, Plan *outer_node, List *outer_tlist, Plan *inner_node, List *inner_tlist); -static HashJoin * -create_hashjoin_node(HashPath *best_path, List *tlist, +static HashJoin *create_hashjoin_node(HashPath *best_path, List *tlist, List *clauses, Plan *outer_node, List *outer_tlist, Plan *inner_node, List *inner_tlist); static Node *fix_indxqual_references(Node *clause, Path *index_path); -static Temp * -make_temp(List *tlist, List *keys, Oid *operators, +static Temp *make_temp(List *tlist, List *keys, Oid *operators, Plan *plan_node, int temptype); -static IndexScan * -make_indexscan(List *qptlist, List *qpqual, Index scanrelid, - List *indxid, List *indxqual); -static NestLoop * -make_nestloop(List *qptlist, List *qpqual, Plan *lefttree, +static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid, + List *indxid, List *indxqual, Cost cost); +static NestLoop *make_nestloop(List *qptlist, List *qpqual, Plan *lefttree, Plan *righttree); -static HashJoin * -make_hashjoin(List *tlist, List *qpqual, +static HashJoin *make_hashjoin(List *tlist, List *qpqual, List *hashclauses, Plan *lefttree, Plan *righttree); static Hash *make_hash(List *tlist, Var *hashkey, Plan *lefttree); -static MergeJoin * -make_mergesort(List *tlist, List *qpqual, +static MergeJoin *make_mergesort(List *tlist, List *qpqual, List *mergeclauses, Oid opcode, Oid *rightorder, Oid *leftorder, Plan *righttree, Plan *lefttree); -static Material * -make_material(List *tlist, Oid tempid, Plan *lefttree, +static Material *make_material(List *tlist, Oid tempid, Plan *lefttree, int keycount); /* @@ -415,9 +404,8 @@ create_indexscan_node(IndexPath *best_path, qpqual, lfirsti(best_path->path.parent->relids), best_path->indexid, - fixed_indxqual); - - scan_node->scan.plan.cost = best_path->path.path_cost; + fixed_indxqual, + best_path->path.path_cost); return (scan_node); } @@ -960,12 +948,13 @@ make_indexscan(List *qptlist, List *qpqual, Index scanrelid, List *indxid, - List *indxqual) + List *indxqual, + Cost cost) { IndexScan *node = makeNode(IndexScan); Plan *plan = &node->scan.plan; - plan->cost = 0.0; + plan->cost = cost; plan->state = (EState *) NULL; plan->targetlist = qptlist; plan->qual = qpqual; @@ -1117,11 +1106,11 @@ make_material(List *tlist, } Agg * -make_agg(List *tlist, int nagg, Aggreg **aggs) +make_agg(List *tlist, int nagg, Aggreg **aggs, Plan *lefttree) { Agg *node = makeNode(Agg); - node->plan.cost = 0.0; + node->plan.cost = (lefttree ? lefttree->cost : 0); node->plan.state = (EState *) NULL; node->plan.qual = NULL; node->plan.targetlist = tlist; diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index 6b297b6c1a5ff4ec0d5877e682279a15e8c3298d..90d5a632c408ab309c1051f59bfda22315ae1b3b 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -6,7 +6,7 @@ * * 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 @@ /* * prototypes for plan/planmain.c */ -extern Plan * -query_planner(Query *root, +extern Plan *query_planner(Query *root, int command_type, List *tlist, List *qual); @@ -30,15 +29,12 @@ query_planner(Query *root, * prototypes for plan/createplan.c */ extern Plan *create_plan(Path *best_path); -extern SeqScan * -make_seqscan(List *qptlist, List *qpqual, Index scanrelid, +extern SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid, Plan *lefttree); -extern Sort * -make_sort(List *tlist, Oid tempid, Plan *lefttree, +extern Sort *make_sort(List *tlist, Oid tempid, Plan *lefttree, int keycount); -extern Agg *make_agg(List *tlist, int nagg, Aggreg **aggs); -extern Group * -make_group(List *tlist, bool tuplePerGroup, int ngrp, +extern Agg *make_agg(List *tlist, int nagg, Aggreg **aggs, Plan *lefttree); +extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp, AttrNumber *grpColIdx, Sort *lefttree); extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr); extern List *generate_fjoin(List *tlist); @@ -56,11 +52,9 @@ extern void add_missing_vars_to_base_rels(Query *root, List *tlist); * prototypes for plan/setrefs.c */ extern void set_tlist_references(Plan *plan); -extern List * -join_references(List *clauses, List *outer_tlist, +extern List *join_references(List *clauses, List *outer_tlist, List *inner_tlist); -extern List * -index_outerjoin_references(List *inner_indxqual, +extern List *index_outerjoin_references(List *inner_indxqual, List *outer_tlist, Index inner_relid); extern void set_result_tlist_references(Result *resultNode); extern void set_agg_tlist_references(Agg *aggNode);