00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef PATHS_H
00015 #define PATHS_H
00016
00017 #include "nodes/relation.h"
00018
00019
00020
00021
00022
00023 extern bool enable_geqo;
00024 extern int geqo_threshold;
00025
00026
00027 typedef RelOptInfo *(*join_search_hook_type) (PlannerInfo *root,
00028 int levels_needed,
00029 List *initial_rels);
00030 extern PGDLLIMPORT join_search_hook_type join_search_hook;
00031
00032
00033 extern RelOptInfo *make_one_rel(PlannerInfo *root, List *joinlist);
00034 extern RelOptInfo *standard_join_search(PlannerInfo *root, int levels_needed,
00035 List *initial_rels);
00036
00037 #ifdef OPTIMIZER_DEBUG
00038 extern void debug_print_rel(PlannerInfo *root, RelOptInfo *rel);
00039 #endif
00040
00041
00042
00043
00044
00045 extern void create_index_paths(PlannerInfo *root, RelOptInfo *rel);
00046 extern List *generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel,
00047 List *clauses, List *other_clauses,
00048 bool restriction_only);
00049 extern bool relation_has_unique_index_for(PlannerInfo *root, RelOptInfo *rel,
00050 List *restrictlist,
00051 List *exprlist, List *oprlist);
00052 extern bool match_index_to_operand(Node *operand, int indexcol,
00053 IndexOptInfo *index);
00054 extern void expand_indexqual_conditions(IndexOptInfo *index,
00055 List *indexclauses, List *indexclausecols,
00056 List **indexquals_p, List **indexqualcols_p);
00057 extern void check_partial_indexes(PlannerInfo *root, RelOptInfo *rel);
00058 extern Expr *adjust_rowcompare_for_index(RowCompareExpr *clause,
00059 IndexOptInfo *index,
00060 int indexcol,
00061 List **indexcolnos,
00062 bool *var_on_left_p);
00063
00064
00065
00066
00067
00068 extern bool create_or_index_quals(PlannerInfo *root, RelOptInfo *rel);
00069
00070
00071
00072
00073
00074 extern void create_tidscan_paths(PlannerInfo *root, RelOptInfo *rel);
00075
00076
00077
00078
00079
00080 extern void add_paths_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel,
00081 RelOptInfo *outerrel, RelOptInfo *innerrel,
00082 JoinType jointype, SpecialJoinInfo *sjinfo,
00083 List *restrictlist);
00084
00085
00086
00087
00088
00089 extern void join_search_one_level(PlannerInfo *root, int level);
00090 extern RelOptInfo *make_join_rel(PlannerInfo *root,
00091 RelOptInfo *rel1, RelOptInfo *rel2);
00092 extern bool have_join_order_restriction(PlannerInfo *root,
00093 RelOptInfo *rel1, RelOptInfo *rel2);
00094
00095
00096
00097
00098
00099 typedef bool (*ec_matches_callback_type) (PlannerInfo *root,
00100 RelOptInfo *rel,
00101 EquivalenceClass *ec,
00102 EquivalenceMember *em,
00103 void *arg);
00104
00105 extern bool process_equivalence(PlannerInfo *root, RestrictInfo *restrictinfo,
00106 bool below_outer_join);
00107 extern Expr *canonicalize_ec_expression(Expr *expr,
00108 Oid req_type, Oid req_collation);
00109 extern void reconsider_outer_join_clauses(PlannerInfo *root);
00110 extern EquivalenceClass *get_eclass_for_sort_expr(PlannerInfo *root,
00111 Expr *expr,
00112 List *opfamilies,
00113 Oid opcintype,
00114 Oid collation,
00115 Index sortref,
00116 Relids rel,
00117 bool create_it);
00118 extern void generate_base_implied_equalities(PlannerInfo *root);
00119 extern List *generate_join_implied_equalities(PlannerInfo *root,
00120 Relids join_relids,
00121 Relids outer_relids,
00122 RelOptInfo *inner_rel);
00123 extern bool exprs_known_equal(PlannerInfo *root, Node *item1, Node *item2);
00124 extern void add_child_rel_equivalences(PlannerInfo *root,
00125 AppendRelInfo *appinfo,
00126 RelOptInfo *parent_rel,
00127 RelOptInfo *child_rel);
00128 extern void mutate_eclass_expressions(PlannerInfo *root,
00129 Node *(*mutator) (),
00130 void *context,
00131 bool include_child_exprs);
00132 extern List *generate_implied_equalities_for_column(PlannerInfo *root,
00133 RelOptInfo *rel,
00134 ec_matches_callback_type callback,
00135 void *callback_arg,
00136 Relids prohibited_rels);
00137 extern bool have_relevant_eclass_joinclause(PlannerInfo *root,
00138 RelOptInfo *rel1, RelOptInfo *rel2);
00139 extern bool has_relevant_eclass_joinclause(PlannerInfo *root,
00140 RelOptInfo *rel1);
00141 extern bool eclass_useful_for_merging(EquivalenceClass *eclass,
00142 RelOptInfo *rel);
00143 extern bool is_redundant_derived_clause(RestrictInfo *rinfo, List *clauselist);
00144
00145
00146
00147
00148
00149 typedef enum
00150 {
00151 PATHKEYS_EQUAL,
00152 PATHKEYS_BETTER1,
00153 PATHKEYS_BETTER2,
00154 PATHKEYS_DIFFERENT
00155 } PathKeysComparison;
00156
00157 extern PathKeysComparison compare_pathkeys(List *keys1, List *keys2);
00158 extern bool pathkeys_contained_in(List *keys1, List *keys2);
00159 extern Path *get_cheapest_path_for_pathkeys(List *paths, List *pathkeys,
00160 Relids required_outer,
00161 CostSelector cost_criterion);
00162 extern Path *get_cheapest_fractional_path_for_pathkeys(List *paths,
00163 List *pathkeys,
00164 Relids required_outer,
00165 double fraction);
00166 extern List *build_index_pathkeys(PlannerInfo *root, IndexOptInfo *index,
00167 ScanDirection scandir);
00168 extern List *convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel,
00169 List *subquery_pathkeys);
00170 extern List *build_join_pathkeys(PlannerInfo *root,
00171 RelOptInfo *joinrel,
00172 JoinType jointype,
00173 List *outer_pathkeys);
00174 extern List *make_pathkeys_for_sortclauses(PlannerInfo *root,
00175 List *sortclauses,
00176 List *tlist);
00177 extern void initialize_mergeclause_eclasses(PlannerInfo *root,
00178 RestrictInfo *restrictinfo);
00179 extern void update_mergeclause_eclasses(PlannerInfo *root,
00180 RestrictInfo *restrictinfo);
00181 extern List *find_mergeclauses_for_pathkeys(PlannerInfo *root,
00182 List *pathkeys,
00183 bool outer_keys,
00184 List *restrictinfos);
00185 extern List *select_outer_pathkeys_for_merge(PlannerInfo *root,
00186 List *mergeclauses,
00187 RelOptInfo *joinrel);
00188 extern List *make_inner_pathkeys_for_merge(PlannerInfo *root,
00189 List *mergeclauses,
00190 List *outer_pathkeys);
00191 extern List *truncate_useless_pathkeys(PlannerInfo *root,
00192 RelOptInfo *rel,
00193 List *pathkeys);
00194 extern bool has_useful_pathkeys(PlannerInfo *root, RelOptInfo *rel);
00195
00196 #endif