1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-27 00:12:01 +03:00

Major planner/optimizer revision: get rid of PathOrder node type,

store all ordering information in pathkeys lists (which are now lists of
lists of PathKeyItem nodes, not just lists of lists of vars).  This was
a big win --- the code is smaller and IMHO more understandable than it
was, even though it handles more cases.  I believe the node changes will
not force an initdb for anyone; planner nodes don't show up in stored
rules.
This commit is contained in:
Tom Lane
1999-08-16 02:17:58 +00:00
parent 08320bfb22
commit e6381966c1
43 changed files with 1937 additions and 3270 deletions

View File

@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: clauses.h,v 1.27 1999/08/12 04:32:49 tgl Exp $
* $Id: clauses.h,v 1.28 1999/08/16 02:17:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,7 +40,6 @@ extern List *make_ands_implicit(Expr *clause);
extern List *pull_constant_clauses(List *quals, List **constantQual);
extern void clause_get_relids_vars(Node *clause, Relids *relids, List **vars);
extern int NumRelids(Node *clause);
extern bool is_joinable(Node *clause);
extern List *fix_opids(List *clauses);
extern void get_relattval(Node *clause, int targetrelid,
int *relid, AttrNumber *attno,

View File

@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: joininfo.h,v 1.13 1999/07/15 15:21:22 momjian Exp $
* $Id: joininfo.h,v 1.14 1999/08/16 02:17:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,6 +17,5 @@
extern JoinInfo *joininfo_member(List *join_relids, List *joininfo_list);
extern JoinInfo *find_joininfo_node(RelOptInfo *this_rel, List *join_relids);
extern Var *other_join_clause_var(Var *var, Expr *clause);
#endif /* JOININFO_H */

View File

@@ -1,23 +0,0 @@
/*-------------------------------------------------------------------------
*
* keys.h
* prototypes for keys.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: keys.h,v 1.16 1999/07/15 15:21:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef KEYS_H
#define KEYS_H
#include "nodes/relation.h"
extern bool match_indexkey_operand(int indexkey, Var *operand, RelOptInfo *rel);
extern Var *extract_join_key(JoinKey *jk, int outer_or_inner);
extern bool pathkeys_match(List *keys1, List *keys2, int *better_key);
extern List *collect_index_pathkeys(int *index_keys, List *tlist);
#endif /* KEYS_H */

View File

@@ -1,25 +0,0 @@
/*-------------------------------------------------------------------------
*
* ordering.h
* prototypes for ordering.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: ordering.h,v 1.15 1999/07/15 23:03:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef ORDERING_H
#define ORDERING_H
#include "nodes/relation.h"
extern bool pathorder_match(PathOrder *path_ordering1,
PathOrder *path_ordering2, int *better_sort);
extern bool equal_path_merge_ordering(Oid *path_ordering,
MergeOrder *merge_ordering);
extern bool equal_merge_ordering(MergeOrder *merge_ordering1,
MergeOrder *merge_ordering2);
#endif /* ORDERING_H */

View File

@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pathnode.h,v 1.20 1999/08/06 04:00:13 tgl Exp $
* $Id: pathnode.h,v 1.21 1999/08/16 02:17:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,22 +20,26 @@
*/
extern bool path_is_cheaper(Path *path1, Path *path2);
extern Path *set_cheapest(RelOptInfo *parent_rel, List *pathlist);
extern List *add_pathlist(RelOptInfo *parent_rel, List *unique_paths,
List *new_paths);
extern List *add_pathlist(RelOptInfo *parent_rel, List *old_paths,
List *new_paths);
extern Path *create_seqscan_path(RelOptInfo *rel);
extern IndexPath *create_index_path(Query *root, RelOptInfo *rel, RelOptInfo *index,
List *restriction_clauses);
extern NestPath *create_nestloop_path(RelOptInfo *joinrel, RelOptInfo *outer_rel,
Path *outer_path, Path *inner_path, List *pathkeys);
extern IndexPath *create_index_path(Query *root, RelOptInfo *rel,
RelOptInfo *index, List *restriction_clauses);
extern NestPath *create_nestloop_path(RelOptInfo *joinrel,
RelOptInfo *outer_rel, Path *outer_path, Path *inner_path,
List *pathkeys);
extern MergePath *create_mergejoin_path(RelOptInfo *joinrel, int outersize,
int innersize, int outerwidth, int innerwidth, Path *outer_path,
Path *inner_path, List *pathkeys, MergeOrder *order,
List *mergeclauses, List *outersortkeys, List *innersortkeys);
int innersize, int outerwidth, int innerwidth, Path *outer_path,
Path *inner_path, List *pathkeys,
List *mergeclauses, List *outersortkeys, List *innersortkeys);
extern HashPath *create_hashjoin_path(RelOptInfo *joinrel, int outersize,
int innersize, int outerwidth, int innerwidth, Path *outer_path,
Path *inner_path, List *pathkeys, Oid operator, List *hashclauses,
List *outerkeys, List *innerkeys, Cost innerdisbursion);
Path *inner_path, List *hashclauses, Cost innerdisbursion);
/*
* prototypes for rel.c

View File

@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: paths.h,v 1.33 1999/07/27 06:23:11 tgl Exp $
* $Id: paths.h,v 1.34 1999/08/16 02:17:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -43,35 +43,28 @@ extern void update_rels_pathlist_for_joins(Query *root, List *joinrels);
extern List *create_or_index_paths(Query *root, RelOptInfo *rel, List *clauses);
/*
* hashutils.c
* routines to deal with hash keys and clauses
* pathkeys.c
* utilities for matching and building path keys
*/
extern List *group_clauses_by_hashop(List *restrictinfo_list,
Relids inner_relids);
typedef enum
{
PATHKEYS_EQUAL, /* pathkeys are identical */
PATHKEYS_BETTER1, /* pathkey 1 is a superset of pathkey 2 */
PATHKEYS_BETTER2, /* vice versa */
PATHKEYS_DIFFERENT /* neither pathkey includes the other */
} PathKeysComparison;
/*
* joinutils.c
* generic join method key/clause routines
*/
extern bool order_joinkeys_by_pathkeys(List *pathkeys,
List *joinkeys, List *joinclauses, int outer_or_inner,
List **matchedJoinKeysPtr,
List **matchedJoinClausesPtr);
extern List *make_pathkeys_from_joinkeys(List *joinkeys, List *tlist,
int outer_or_inner);
extern Path *get_cheapest_path_for_joinkeys(List *joinkeys,
PathOrder *ordering, List *paths, int outer_or_inner);
extern List *new_join_pathkeys(List *outer_pathkeys,
List *join_rel_tlist, List *joinclauses);
/*
* mergeutils.c
* routines to deal with merge keys and clauses
*/
extern List *group_clauses_by_order(List *restrictinfo_list,
Relids inner_relids);
extern MergeInfo *match_order_mergeinfo(PathOrder *ordering,
List *mergeinfo_list);
extern PathKeysComparison compare_pathkeys(List *keys1, List *keys2);
extern bool pathkeys_contained_in(List *keys1, List *keys2);
extern Path *get_cheapest_path_for_pathkeys(List *paths, List *pathkeys);
extern List *build_index_pathkeys(Query *root, RelOptInfo *rel,
RelOptInfo *index);
extern List *build_join_pathkeys(List *outer_pathkeys,
List *join_rel_tlist, List *joinclauses);
extern List *find_mergeclauses_for_pathkeys(List *pathkeys,
List *restrictinfos);
extern List *make_pathkeys_for_mergeclauses(List *mergeclauses,
List *tlist);
/*
* joinrels.c

View File

@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: tlist.h,v 1.19 1999/07/15 15:21:23 momjian Exp $
* $Id: tlist.h,v 1.20 1999/08/16 02:17:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,4 +30,7 @@ extern List *flatten_tlist(List *tlist);
extern List *flatten_tlist_vars(List *full_tlist,
List *flat_tlist);
extern Var *get_expr(TargetEntry *tle);
extern Var *get_groupclause_expr(GroupClause *groupClause, List *targetList);
#endif /* TLIST_H */