PostgreSQL Source Code git master
Loading...
Searching...
No Matches
paths.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * paths.h
4 * prototypes for various files in optimizer/path
5 *
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/optimizer/paths.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef PATHS_H
15#define PATHS_H
16
17#include "nodes/pathnodes.h"
18
19
20/*
21 * allpaths.c
22 */
23extern PGDLLIMPORT bool enable_geqo;
30
31/* Hooks for plugins to get control in set_rel_pathlist() */
33 RelOptInfo *joinrel,
34 RelOptInfo *outerrel,
35 RelOptInfo *innerrel,
36 JoinType jointype,
37 JoinPathExtraData *extra);
40 RelOptInfo *rel,
41 Index rti,
44
45/* Hook for plugins to get control in add_paths_to_joinrel() */
47 RelOptInfo *joinrel,
48 RelOptInfo *outerrel,
49 RelOptInfo *innerrel,
50 JoinType jointype,
51 JoinPathExtraData *extra);
53
54/* Hook for plugins to replace standard_join_search() */
55typedef RelOptInfo *(*join_search_hook_type) (PlannerInfo *root,
56 int levels_needed,
57 List *initial_rels);
59
60
63 List *initial_rels);
64
66 bool override_rows);
68 bool override_rows);
69extern void generate_grouped_paths(PlannerInfo *root, RelOptInfo *grouped_rel,
70 RelOptInfo *rel);
71extern int compute_parallel_worker(RelOptInfo *rel, double heap_pages,
72 double index_pages, int max_workers);
74 Path *bitmapqual);
76 RelOptInfo *rel);
77
78/*
79 * indxpath.c
80 * routines to generate index paths
81 */
84 List *restrictlist,
85 List **extra_clauses);
88 int indexcol);
89extern bool match_index_to_operand(Node *operand, int indexcol,
91extern Node *strip_phvs_in_index_operand(Node *operand);
93
94/*
95 * tidpath.c
96 * routines to generate tid paths
97 */
99
100/*
101 * joinpath.c
102 * routines to create join paths
103 */
104extern void add_paths_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel,
105 RelOptInfo *outerrel, RelOptInfo *innerrel,
106 JoinType jointype, SpecialJoinInfo *sjinfo,
107 List *restrictlist);
108
109/*
110 * joinrels.c
111 * routines to determine which relations to join
112 */
113extern void join_search_one_level(PlannerInfo *root, int level);
117 SpecialJoinInfo *sjinfo,
121extern void mark_dummy_rel(RelOptInfo *rel);
124
125/*
126 * equivclass.c
127 * routines for managing EquivalenceClasses
128 */
130 RelOptInfo *rel,
133 void *arg);
134
137 JoinDomain *jdomain);
143 Expr *expr,
145 Oid opcintype,
146 Oid collation,
148 Relids rel,
149 bool create_it);
151 Expr *expr,
152 Relids relids);
155 List *exprs,
156 Relids relids,
163 Relids join_relids,
164 Relids outer_relids,
166 SpecialJoinInfo *sjinfo);
168 List *eclasses,
169 Relids join_relids,
170 Relids outer_relids,
173 Oid opfamily);
176 int colno);
185 int nappinfos,
186 AppendRelInfo **appinfos,
192 List *setop_pathkeys);
195 Relids child_relids);
198 RelOptInfo *rel,
200 void *callback_arg,
208 RelOptInfo *rel);
211 List *indexclauses);
213
214/*
215 * pathkeys.c
216 * utilities for matching and building path keys
217 */
218typedef enum
219{
220 PATHKEYS_EQUAL, /* pathkeys are identical */
221 PATHKEYS_BETTER1, /* pathkey 1 is a superset of pathkey 2 */
222 PATHKEYS_BETTER2, /* vice versa */
223 PATHKEYS_DIFFERENT, /* neither pathkey includes the other */
225
230extern Path *get_cheapest_path_for_pathkeys(List *paths, List *pathkeys,
235 List *pathkeys,
237 double fraction);
244 Oid opno,
245 Relids rel, bool create_it);
250 RelOptInfo *joinrel,
251 JoinType jointype,
255 List *tlist);
258 List *tlist,
259 bool remove_redundant,
261 bool *sortable,
262 bool set_ec_sortref);
268 List *pathkeys,
271 List *mergeclauses,
272 RelOptInfo *joinrel);
274 List *mergeclauses,
277 List *mergeclauses,
278 List *pathkeys);
280 RelOptInfo *rel,
281 List *pathkeys);
283extern List *append_pathkeys(List *target, List *source);
285 EquivalenceClass *eclass, Oid opfamily,
286 CompareType cmptype, bool nulls_first);
289
290#endif /* PATHS_H */
#define PGDLLIMPORT
Definition c.h:1334
unsigned int Index
Definition c.h:628
CompareType
Definition cmptype.h:32
JoinType
Definition nodes.h:298
CostSelector
Definition pathnodes.h:110
PathKey * make_canonical_pathkey(PlannerInfo *root, EquivalenceClass *eclass, Oid opfamily, CompareType cmptype, bool nulls_first)
Definition pathkeys.c:56
List * truncate_useless_pathkeys(PlannerInfo *root, RelOptInfo *rel, List *pathkeys)
Definition pathkeys.c:2200
void rebuild_eclass_attr_needed(PlannerInfo *root)
EquivalenceClass * get_eclass_for_sort_expr(PlannerInfo *root, Expr *expr, List *opfamilies, Oid opcintype, Oid collation, Index sortref, Relids rel, bool create_it)
Definition equivclass.c:736
void add_child_rel_equivalences(PlannerInfo *root, AppendRelInfo *appinfo, RelOptInfo *parent_rel, RelOptInfo *child_rel)
bool is_redundant_with_indexclauses(RestrictInfo *rinfo, List *indexclauses)
void generate_base_implied_equalities(PlannerInfo *root)
bool exprs_known_equal(PlannerInfo *root, Node *item1, Node *item2, Oid opfamily)
PGDLLIMPORT int geqo_threshold
Definition allpaths.c:83
void generate_partitionwise_join_paths(PlannerInfo *root, RelOptInfo *rel)
Definition allpaths.c:4814
void join_search_one_level(PlannerInfo *root, int level)
Definition joinrels.c:78
Path * get_cheapest_fractional_path_for_pathkeys(List *paths, List *pathkeys, Relids required_outer, double fraction)
Definition pathkeys.c:666
void generate_grouped_paths(PlannerInfo *root, RelOptInfo *grouped_rel, RelOptInfo *rel)
Definition allpaths.c:3442
PGDLLIMPORT set_rel_pathlist_hook_type set_rel_pathlist_hook
Definition allpaths.c:89
Expr * canonicalize_ec_expression(Expr *expr, Oid req_type, Oid req_collation)
Definition equivclass.c:545
List * append_pathkeys(List *target, List *source)
Definition pathkeys.c:107
void(* join_path_setup_hook_type)(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinType jointype, JoinPathExtraData *extra)
Definition paths.h:32
Path * get_cheapest_path_for_pathkeys(List *paths, List *pathkeys, Relids required_outer, CostSelector cost_criterion, bool require_parallel_safe)
Definition pathkeys.c:620
EquivalenceMember * find_ec_member_matching_expr(EquivalenceClass *ec, Expr *expr, Relids relids)
Definition equivclass.c:916
bool pathkeys_count_contained_in(List *keys1, List *keys2, int *n_common)
Definition pathkeys.c:558
PGDLLIMPORT bool enable_eager_aggregate
Definition allpaths.c:82
List * make_inner_pathkeys_for_merge(PlannerInfo *root, List *mergeclauses, List *outer_pathkeys)
Definition pathkeys.c:1858
RelOptInfo * make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
Definition joinrels.c:699
bool relation_can_be_sorted_early(PlannerInfo *root, RelOptInfo *rel, EquivalenceClass *ec, bool require_parallel_safe)
void setup_eclass_member_iterator(EquivalenceMemberIterator *it, EquivalenceClass *ec, Relids child_relids)
void add_paths_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinType jointype, SpecialJoinInfo *sjinfo, List *restrictlist)
Definition joinpath.c:123
RelOptInfo * standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
Definition allpaths.c:3885
Node * strip_phvs_in_index_operand(Node *operand)
Definition indxpath.c:4449
PGDLLIMPORT bool enable_group_by_reordering
Definition pathkeys.c:32
bool has_useful_pathkeys(PlannerInfo *root, RelOptInfo *rel)
Definition pathkeys.c:2291
void ec_clear_derived_clauses(EquivalenceClass *ec)
Relids add_outer_joins_to_relids(PlannerInfo *root, Relids input_relids, SpecialJoinInfo *sjinfo, List **pushed_down_joins)
Definition joinrels.c:800
void(* set_join_pathlist_hook_type)(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinType jointype, JoinPathExtraData *extra)
Definition paths.h:46
void check_index_predicates(PlannerInfo *root, RelOptInfo *rel)
Definition indxpath.c:3941
bool process_equivalence(PlannerInfo *root, RestrictInfo **p_restrictinfo, JoinDomain *jdomain)
Definition equivclass.c:179
PGDLLIMPORT double min_eager_agg_group_size
Definition allpaths.c:84
int compute_parallel_worker(RelOptInfo *rel, double heap_pages, double index_pages, int max_workers)
Definition allpaths.c:4726
List * build_index_pathkeys(PlannerInfo *root, IndexOptInfo *index, ScanDirection scandir)
Definition pathkeys.c:740
void generate_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_rows)
Definition allpaths.c:3188
List * find_mergeclauses_for_outer_pathkeys(PlannerInfo *root, List *pathkeys, List *restrictinfos)
Definition pathkeys.c:1544
List * generate_implied_equalities_for_column(PlannerInfo *root, RelOptInfo *rel, ec_matches_callback_type callback, void *callback_arg, Relids prohibited_rels)
void(* set_rel_pathlist_hook_type)(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
Definition paths.h:39
void update_mergeclause_eclasses(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition pathkeys.c:1510
EquivalenceMember * eclass_member_iterator_next(EquivalenceMemberIterator *it)
PGDLLIMPORT int min_parallel_table_scan_size
Definition allpaths.c:85
List * make_pathkeys_for_sortclauses(PlannerInfo *root, List *sortclauses, List *tlist)
Definition pathkeys.c:1336
List * trim_mergeclauses_for_inner_pathkeys(PlannerInfo *root, List *mergeclauses, List *pathkeys)
Definition pathkeys.c:1961
RelOptInfo *(* join_search_hook_type)(PlannerInfo *root, int levels_needed, List *initial_rels)
Definition paths.h:55
bool have_relevant_eclass_joinclause(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
void create_index_paths(PlannerInfo *root, RelOptInfo *rel)
Definition indxpath.c:240
List * build_expression_pathkey(PlannerInfo *root, Expr *expr, Oid opno, Relids rel, bool create_it)
Definition pathkeys.c:1000
EquivalenceMember * find_computable_ec_member(PlannerInfo *root, EquivalenceClass *ec, List *exprs, Relids relids, bool require_parallel_safe)
Definition equivclass.c:991
List * build_partition_pathkeys(PlannerInfo *root, RelOptInfo *partrel, ScanDirection scandir, bool *partialkeys)
Definition pathkeys.c:919
List * generate_join_implied_equalities_for_ecs(PlannerInfo *root, List *eclasses, Relids join_relids, Relids outer_relids, RelOptInfo *inner_rel)
void generate_useful_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_rows)
Definition allpaths.c:3325
List * select_outer_pathkeys_for_merge(PlannerInfo *root, List *mergeclauses, RelOptInfo *joinrel)
Definition pathkeys.c:1659
List * convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel, List *subquery_pathkeys, List *subquery_tlist)
Definition pathkeys.c:1054
void mark_dummy_rel(RelOptInfo *rel)
Definition joinrels.c:1513
void add_setop_child_rel_equivalences(PlannerInfo *root, RelOptInfo *child_rel, List *child_tlist, List *setop_pathkeys)
void reconsider_outer_join_clauses(PlannerInfo *root)
bool have_join_order_restriction(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
Definition joinrels.c:1254
bool eclass_useful_for_merging(PlannerInfo *root, EquivalenceClass *eclass, RelOptInfo *rel)
PGDLLIMPORT int min_parallel_index_scan_size
Definition allpaths.c:86
void add_child_join_rel_equivalences(PlannerInfo *root, int nappinfos, AppendRelInfo **appinfos, RelOptInfo *parent_joinrel, RelOptInfo *child_joinrel)
List * make_pathkeys_for_sortclauses_extended(PlannerInfo *root, List **sortclauses, List *tlist, bool remove_redundant, bool remove_group_rtindex, bool *sortable, bool set_ec_sortref)
Definition pathkeys.c:1381
void initialize_mergeclause_eclasses(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition pathkeys.c:1463
RelOptInfo * make_one_rel(PlannerInfo *root, List *joinlist)
Definition allpaths.c:177
bool create_tidscan_paths(PlannerInfo *root, RelOptInfo *rel)
Definition tidpath.c:497
bool match_index_to_operand(Node *operand, int indexcol, IndexOptInfo *index)
Definition indxpath.c:4354
void init_dummy_sjinfo(SpecialJoinInfo *sjinfo, Relids left_relids, Relids right_relids)
Definition joinrels.c:664
bool is_redundant_derived_clause(RestrictInfo *rinfo, List *clauselist)
RestrictInfo * find_derived_clause_for_ec_member(PlannerInfo *root, EquivalenceClass *ec, EquivalenceMember *em)
void create_partial_bitmap_paths(PlannerInfo *root, RelOptInfo *rel, Path *bitmapqual)
Definition allpaths.c:4690
PGDLLIMPORT join_path_setup_hook_type join_path_setup_hook
Definition joinpath.c:32
bool pathkeys_contained_in(List *keys1, List *keys2)
Definition pathkeys.c:343
List * build_join_pathkeys(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, List *outer_pathkeys)
Definition pathkeys.c:1295
PathKeysComparison compare_pathkeys(List *keys1, List *keys2)
Definition pathkeys.c:304
PGDLLIMPORT join_search_hook_type join_search_hook
Definition allpaths.c:92
void add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, List *live_childrels)
Definition allpaths.c:1404
EquivalenceClass * match_eclasses_to_foreign_key_col(PlannerInfo *root, ForeignKeyOptInfo *fkinfo, int colno)
PathKeysComparison
Definition paths.h:219
@ PATHKEYS_BETTER2
Definition paths.h:222
@ PATHKEYS_BETTER1
Definition paths.h:221
@ PATHKEYS_DIFFERENT
Definition paths.h:223
@ PATHKEYS_EQUAL
Definition paths.h:220
Path * get_cheapest_parallel_safe_total_inner(List *paths)
Definition pathkeys.c:699
bool indexcol_is_bool_constant_for_query(PlannerInfo *root, IndexOptInfo *index, int indexcol)
Definition indxpath.c:4303
List * generate_join_implied_equalities(PlannerInfo *root, Relids join_relids, Relids outer_relids, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo)
bool has_relevant_eclass_joinclause(PlannerInfo *root, RelOptInfo *rel1)
PGDLLIMPORT bool enable_geqo
Definition allpaths.c:81
bool(* ec_matches_callback_type)(PlannerInfo *root, RelOptInfo *rel, EquivalenceClass *ec, EquivalenceMember *em, void *arg)
Definition paths.h:129
List * get_useful_group_keys_orderings(PlannerInfo *root, Path *path)
Definition pathkeys.c:467
PGDLLIMPORT set_join_pathlist_hook_type set_join_pathlist_hook
Definition joinpath.c:31
bool relation_has_unique_index_for(PlannerInfo *root, RelOptInfo *rel, List *restrictlist, List **extra_clauses)
Definition indxpath.c:4145
void * arg
static rewind_source * source
Definition pg_rewind.c:89
unsigned int Oid
static int fb(int x)
tree ctl root
Definition radixtree.h:1857
static struct cvec * eclass(struct vars *v, chr c, int cases)
ScanDirection
Definition sdir.h:25
Definition pg_list.h:54
Definition nodes.h:135
Definition type.h:96
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)