PostgreSQL Source Code  git master
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pathnode.h
4  * prototypes for pathnode.c, relnode.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/optimizer/pathnode.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef PATHNODE_H
15 #define PATHNODE_H
17 #include "nodes/bitmapset.h"
18 #include "nodes/pathnodes.h"
21 /*
22  * prototypes for pathnode.c
23  */
24 extern int compare_path_costs(Path *path1, Path *path2,
25  CostSelector criterion);
26 extern int compare_fractional_path_costs(Path *path1, Path *path2,
27  double fraction);
28 extern void set_cheapest(RelOptInfo *parent_rel);
29 extern void add_path(RelOptInfo *parent_rel, Path *new_path);
30 extern bool add_path_precheck(RelOptInfo *parent_rel,
31  Cost startup_cost, Cost total_cost,
32  List *pathkeys, Relids required_outer);
33 extern void add_partial_path(RelOptInfo *parent_rel, Path *new_path);
34 extern bool add_partial_path_precheck(RelOptInfo *parent_rel,
35  Cost total_cost, List *pathkeys);
38  Relids required_outer, int parallel_workers);
40  Relids required_outer);
43  List *indexclauses,
44  List *indexorderbys,
45  List *indexorderbycols,
46  List *pathkeys,
47  ScanDirection indexscandir,
48  bool indexonly,
49  Relids required_outer,
50  double loop_count,
51  bool partial_path);
53  RelOptInfo *rel,
54  Path *bitmapqual,
55  Relids required_outer,
56  double loop_count,
57  int parallel_degree);
59  RelOptInfo *rel,
60  List *bitmapquals);
62  RelOptInfo *rel,
63  List *bitmapquals);
65  List *tidquals, Relids required_outer);
67  RelOptInfo *rel,
68  List *tidrangequals,
69  Relids required_outer);
71  List *subpaths, List *partial_subpaths,
72  List *pathkeys, Relids required_outer,
73  int parallel_workers, bool parallel_aware,
74  double rows);
76  RelOptInfo *rel,
77  List *subpaths,
78  List *pathkeys,
79  Relids required_outer);
81  RelOptInfo *rel,
82  PathTarget *target,
83  List *havingqual);
86  RelOptInfo *rel,
87  Path *subpath,
88  List *param_exprs,
89  List *hash_operators,
90  bool singlerow,
91  bool binary_mode,
92  double calls);
94  Path *subpath, SpecialJoinInfo *sjinfo);
96  RelOptInfo *rel, Path *subpath, PathTarget *target,
97  Relids required_outer, double *rows);
99  RelOptInfo *rel,
100  Path *subpath,
101  PathTarget *target,
102  List *pathkeys,
103  Relids required_outer,
104  double *rows);
106  RelOptInfo *rel,
107  Path *subpath,
108  bool trivial_pathtarget,
109  List *pathkeys,
110  Relids required_outer);
112  List *pathkeys, Relids required_outer);
114  Relids required_outer);
116  Relids required_outer);
118  List *pathkeys, Relids required_outer);
120  Relids required_outer);
122  Relids required_outer);
124  Relids required_outer);
126  PathTarget *target,
127  double rows, Cost startup_cost, Cost total_cost,
128  List *pathkeys,
129  Relids required_outer,
130  Path *fdw_outerpath,
131  List *fdw_restrictinfo,
132  List *fdw_private);
134  PathTarget *target,
135  double rows, Cost startup_cost, Cost total_cost,
136  List *pathkeys,
137  Relids required_outer,
138  Path *fdw_outerpath,
139  List *fdw_restrictinfo,
140  List *fdw_private);
142  PathTarget *target,
143  double rows, Cost startup_cost, Cost total_cost,
144  List *pathkeys,
145  Path *fdw_outerpath,
146  List *fdw_restrictinfo,
147  List *fdw_private);
149 extern Relids calc_nestloop_required_outer(Relids outerrelids,
150  Relids outer_paramrels,
151  Relids innerrelids,
152  Relids inner_paramrels);
153 extern Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path);
156  RelOptInfo *joinrel,
157  JoinType jointype,
158  JoinCostWorkspace *workspace,
159  JoinPathExtraData *extra,
160  Path *outer_path,
161  Path *inner_path,
162  List *restrict_clauses,
163  List *pathkeys,
164  Relids required_outer);
167  RelOptInfo *joinrel,
168  JoinType jointype,
169  JoinCostWorkspace *workspace,
170  JoinPathExtraData *extra,
171  Path *outer_path,
172  Path *inner_path,
173  List *restrict_clauses,
174  List *pathkeys,
175  Relids required_outer,
176  List *mergeclauses,
177  List *outersortkeys,
178  List *innersortkeys);
181  RelOptInfo *joinrel,
182  JoinType jointype,
183  JoinCostWorkspace *workspace,
184  JoinPathExtraData *extra,
185  Path *outer_path,
186  Path *inner_path,
187  bool parallel_hash,
188  List *restrict_clauses,
189  Relids required_outer,
190  List *hashclauses);
193  RelOptInfo *rel,
194  Path *subpath,
195  PathTarget *target);
197  RelOptInfo *rel,
198  Path *path,
199  PathTarget *target);
201  RelOptInfo *rel,
202  Path *subpath,
203  PathTarget *target);
205  RelOptInfo *rel,
206  Path *subpath,
207  List *pathkeys,
208  double limit_tuples);
210  RelOptInfo *rel,
211  Path *subpath,
212  List *pathkeys,
213  int presorted_keys,
214  double limit_tuples);
216  RelOptInfo *rel,
217  Path *subpath,
218  List *groupClause,
219  List *qual,
220  double numGroups);
222  RelOptInfo *rel,
223  Path *subpath,
224  int numCols,
225  double numGroups);
227  RelOptInfo *rel,
228  Path *subpath,
229  PathTarget *target,
230  AggStrategy aggstrategy,
231  AggSplit aggsplit,
232  List *groupClause,
233  List *qual,
234  const AggClauseCosts *aggcosts,
235  double numGroups);
237  RelOptInfo *rel,
238  Path *subpath,
239  List *having_qual,
240  AggStrategy aggstrategy,
241  List *rollups,
242  const AggClauseCosts *agg_costs);
244  RelOptInfo *rel,
245  PathTarget *target,
246  List *mmaggregates,
247  List *quals);
249  RelOptInfo *rel,
250  Path *subpath,
251  PathTarget *target,
252  List *windowFuncs,
253  List *runCondition,
254  WindowClause *winclause,
255  List *qual,
256  bool topwindow);
258  RelOptInfo *rel,
259  Path *subpath,
260  SetOpCmd cmd,
261  SetOpStrategy strategy,
262  List *distinctList,
263  AttrNumber flagColIdx,
264  int firstFlag,
265  double numGroups,
266  double outputRows);
268  RelOptInfo *rel,
269  Path *leftpath,
270  Path *rightpath,
271  PathTarget *target,
272  List *distinctList,
273  int wtParam,
274  double numGroups);
276  Path *subpath, List *rowMarks, int epqParam);
278  RelOptInfo *rel,
279  Path *subpath,
280  CmdType operation, bool canSetTag,
281  Index nominalRelation, Index rootRelation,
282  bool partColsUpdated,
283  List *resultRelations,
284  List *updateColnosLists,
285  List *withCheckOptionLists, List *returningLists,
286  List *rowMarks, OnConflictExpr *onconflict,
287  List *mergeActionLists, List *mergeJoinConditions,
288  int epqParam);
290  Path *subpath,
291  Node *limitOffset, Node *limitCount,
292  LimitOption limitOption,
293  int64 offset_est, int64 count_est);
294 extern void adjust_limit_rows_costs(double *rows,
295  Cost *startup_cost, Cost *total_cost,
296  int64 offset_est, int64 count_est);
299  Relids required_outer,
300  double loop_count);
302  RelOptInfo *child_rel);
303 extern bool path_is_reparameterizable_by_child(Path *path,
304  RelOptInfo *child_rel);
306 /*
307  * prototypes for relnode.c
308  */
311 extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid,
312  RelOptInfo *parent);
313 extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid);
314 extern RelOptInfo *find_base_rel_noerr(PlannerInfo *root, int relid);
318  Relids joinrelids,
319  RelOptInfo *outer_rel,
320  RelOptInfo *inner_rel,
321  SpecialJoinInfo *sjinfo,
322  List *pushed_down_joins,
323  List **restrictlist_ptr);
325  Relids joinrelids,
326  RelOptInfo *outer_rel,
327  RelOptInfo *inner_rel);
329  Relids relids);
332  RelOptInfo *baserel,
333  Relids required_outer);
335  RelOptInfo *joinrel,
336  Path *outer_path,
337  Path *inner_path,
338  SpecialJoinInfo *sjinfo,
339  Relids required_outer,
340  List **restrict_clauses);
342  Relids required_outer);
344  Relids required_outer);
347  RelOptInfo *outer_rel, RelOptInfo *inner_rel,
348  RelOptInfo *parent_joinrel, List *restrictlist,
349  SpecialJoinInfo *sjinfo);
351 #endif /* PATHNODE_H */
int16 AttrNumber
Definition: attnum.h:21
unsigned int Index
Definition: c.h:614
Datum subpath(PG_FUNCTION_ARGS)
Definition: ltree_op.c:310
Definition: nodes.h:397
Definition: nodes.h:405
double Cost
Definition: nodes.h:251
Definition: nodes.h:263
Definition: nodes.h:353
Definition: nodes.h:375
Definition: nodes.h:430
Definition: nodes.h:288
AppendPath * create_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *partial_subpaths, List *pathkeys, Relids required_outer, int parallel_workers, bool parallel_aware, double rows)
Definition: pathnode.c:1244
void setup_simple_rel_arrays(PlannerInfo *root)
Definition: relnode.c:94
SortPath * create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, double limit_tuples)
Definition: pathnode.c:3000
TidPath * create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, List *tidquals, Relids required_outer)
Definition: pathnode.c:1179
ParamPathInfo * get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, Relids required_outer)
Definition: relnode.c:1557
GroupResultPath * create_group_result_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *havingqual)
Definition: pathnode.c:1518
NestPath * create_nestloop_path(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, JoinCostWorkspace *workspace, JoinPathExtraData *extra, Path *outer_path, Path *inner_path, List *restrict_clauses, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2457
Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path)
Definition: pathnode.c:2405
UniquePath * create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, SpecialJoinInfo *sjinfo)
Definition: pathnode.c:1654
RelOptInfo * build_join_rel(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List *pushed_down_joins, List **restrictlist_ptr)
Definition: relnode.c:665
bool path_is_reparameterizable_by_child(Path *path, RelOptInfo *child_rel)
Definition: pathnode.c:4411
IndexPath * create_index_path(PlannerInfo *root, IndexOptInfo *index, List *indexclauses, List *indexorderbys, List *indexorderbycols, List *pathkeys, ScanDirection indexscandir, bool indexonly, Relids required_outer, double loop_count, bool partial_path)
Definition: pathnode.c:993
LimitPath * create_limit_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, Node *limitOffset, Node *limitCount, LimitOption limitOption, int64 offset_est, int64 count_est)
Definition: pathnode.c:3826
ProjectionPath * create_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2685
GatherMergePath * create_gather_merge_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *pathkeys, Relids required_outer, double *rows)
Definition: pathnode.c:1881
UpperUniquePath * create_upper_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, int numCols, double numGroups)
Definition: pathnode.c:3103
Relids calc_nestloop_required_outer(Relids outerrelids, Relids outer_paramrels, Relids innerrelids, Relids inner_paramrels)
Definition: pathnode.c:2378
Path * create_tablefuncscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2072
Path * create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2150
Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
Definition: relnode.c:1034
LockRowsPath * create_lockrows_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *rowMarks, int epqParam)
Definition: pathnode.c:3662
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
Definition: relnode.c:414
ParamPathInfo * get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
Definition: relnode.c:1868
RelOptInfo * build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
Definition: relnode.c:192
Path * reparameterize_path_by_child(PlannerInfo *root, Path *path, RelOptInfo *child_rel)
Definition: pathnode.c:4115
MergePath * create_mergejoin_path(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, JoinCostWorkspace *workspace, JoinPathExtraData *extra, Path *outer_path, Path *inner_path, List *restrict_clauses, List *pathkeys, Relids required_outer, List *mergeclauses, List *outersortkeys, List *innersortkeys)
Definition: pathnode.c:2553
GatherPath * create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, Relids required_outer, double *rows)
Definition: pathnode.c:1972
Path * create_resultscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2176
Path * create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:952
MemoizePath * create_memoize_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *param_exprs, List *hash_operators, bool singlerow, bool binary_mode, double calls)
Definition: pathnode.c:1598
MergeAppendPath * create_merge_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *pathkeys, Relids required_outer)
Definition: pathnode.c:1415
void set_cheapest(RelOptInfo *parent_rel)
Definition: pathnode.c:242
Relids find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
Definition: relnode.c:1521
Path * reparameterize_path(PlannerInfo *root, Path *path, Relids required_outer, double loop_count)
Definition: pathnode.c:3949
void expand_planner_arrays(PlannerInfo *root, int add_size)
Definition: relnode.c:163
ProjectSetPath * create_set_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2882
SubqueryScanPath * create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, bool trivial_pathtarget, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2016
ForeignPath * create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
Definition: pathnode.c:2235
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
Definition: relnode.c:527
ForeignPath * create_foreign_upper_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
Definition: pathnode.c:2333
void add_partial_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:747
ParamPathInfo * get_joinrel_parampathinfo(PlannerInfo *root, RelOptInfo *joinrel, Path *outer_path, Path *inner_path, SpecialJoinInfo *sjinfo, Relids required_outer, List **restrict_clauses)
Definition: relnode.c:1671
MaterialPath * create_material_path(RelOptInfo *rel, Path *subpath)
Definition: pathnode.c:1566
Path * create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2046
BitmapOrPath * create_bitmap_or_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals)
Definition: pathnode.c:1127
int compare_fractional_path_costs(Path *path1, Path *path2, double fraction)
Definition: pathnode.c:115
GroupPath * create_group_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *groupClause, List *qual, double numGroups)
Definition: pathnode.c:3044
RelOptInfo * find_base_rel_ignore_join(PlannerInfo *root, int relid)
Definition: relnode.c:454
HashPath * create_hashjoin_path(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, JoinCostWorkspace *workspace, JoinPathExtraData *extra, Path *outer_path, Path *inner_path, bool parallel_hash, List *restrict_clauses, Relids required_outer, List *hashclauses)
Definition: pathnode.c:2619
RelOptInfo * find_base_rel_noerr(PlannerInfo *root, int relid)
Definition: relnode.c:436
bool add_partial_path_precheck(RelOptInfo *parent_rel, Cost total_cost, List *pathkeys)
Definition: pathnode.c:865
GroupingSetsPath * create_groupingsets_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *having_qual, AggStrategy aggstrategy, List *rollups, const AggClauseCosts *agg_costs)
Definition: pathnode.c:3237
SetOpPath * create_setop_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, SetOpCmd cmd, SetOpStrategy strategy, List *distinctList, AttrNumber flagColIdx, int firstFlag, double numGroups, double outputRows)
Definition: pathnode.c:3555
RecursiveUnionPath * create_recursiveunion_path(PlannerInfo *root, RelOptInfo *rel, Path *leftpath, Path *rightpath, PathTarget *target, List *distinctList, int wtParam, double numGroups)
Definition: pathnode.c:3617
RelOptInfo * build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel, RelOptInfo *parent_joinrel, List *restrictlist, SpecialJoinInfo *sjinfo)
Definition: relnode.c:881
IncrementalSortPath * create_incremental_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, int presorted_keys, double limit_tuples)
Definition: pathnode.c:2951
MinMaxAggPath * create_minmaxagg_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *mmaggregates, List *quals)
Definition: pathnode.c:3397
Path * create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2202
WindowAggPath * create_windowagg_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *windowFuncs, List *runCondition, WindowClause *winclause, List *qual, bool topwindow)
Definition: pathnode.c:3485
AggPath * create_agg_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, AggStrategy aggstrategy, AggSplit aggsplit, List *groupClause, List *qual, const AggClauseCosts *aggcosts, double numGroups)
Definition: pathnode.c:3155
void add_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:420
ModifyTablePath * create_modifytable_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, CmdType operation, bool canSetTag, Index nominalRelation, Index rootRelation, bool partColsUpdated, List *resultRelations, List *updateColnosLists, List *withCheckOptionLists, List *returningLists, List *rowMarks, OnConflictExpr *onconflict, List *mergeActionLists, List *mergeJoinConditions, int epqParam)
Definition: pathnode.c:3725
Path * create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2098
int compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
Definition: pathnode.c:69
ParamPathInfo * find_param_path_info(RelOptInfo *rel, Relids required_outer)
Definition: relnode.c:1901
Path * apply_projection_to_path(PlannerInfo *root, RelOptInfo *rel, Path *path, PathTarget *target)
Definition: pathnode.c:2793
BitmapAndPath * create_bitmap_and_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals)
Definition: pathnode.c:1075
TidRangePath * create_tidrangescan_path(PlannerInfo *root, RelOptInfo *rel, List *tidrangequals, Relids required_outer)
Definition: pathnode.c:1208
Path * create_seqscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer, int parallel_workers)
Definition: pathnode.c:927
void adjust_limit_rows_costs(double *rows, Cost *startup_cost, Cost *total_cost, int64 offset_est, int64 count_est)
Definition: pathnode.c:3881
ForeignPath * create_foreign_join_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
Definition: pathnode.c:2281
RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
Definition: relnode.c:1470
Bitmapset * get_param_path_clause_serials(Path *path)
Definition: relnode.c:1922
Path * create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2124
bool add_path_precheck(RelOptInfo *parent_rel, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer)
Definition: pathnode.c:642
BitmapHeapPath * create_bitmap_heap_path(PlannerInfo *root, RelOptInfo *rel, Path *bitmapqual, Relids required_outer, double loop_count, int parallel_degree)
Definition: pathnode.c:1042
Definition: pathnodes.h:37
Definition: pathnodes.h:70
tree ctl root
Definition: radixtree.h:1886
Definition: sdir.h:25
Size add_size(Size s1, Size s2)
Definition: shmem.c:493
Definition: pg_list.h:54
Definition: nodes.h:129
Definition: type.h:95