PostgreSQL Source Code  git master
pathnode.h
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-2022, 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
16 
17 #include "nodes/bitmapset.h"
18 #include "nodes/pathnodes.h"
19 
20 
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);
36 
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, Path *subpath,
107  List *pathkeys, Relids required_outer);
109  List *pathkeys, Relids required_outer);
111  Relids required_outer);
113  Relids required_outer);
114 extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel,
115  Relids required_outer);
117  Relids required_outer);
119  Relids required_outer);
121  Relids required_outer);
123  PathTarget *target,
124  double rows, Cost startup_cost, Cost total_cost,
125  List *pathkeys,
126  Relids required_outer,
127  Path *fdw_outerpath,
128  List *fdw_private);
130  PathTarget *target,
131  double rows, Cost startup_cost, Cost total_cost,
132  List *pathkeys,
133  Relids required_outer,
134  Path *fdw_outerpath,
135  List *fdw_private);
137  PathTarget *target,
138  double rows, Cost startup_cost, Cost total_cost,
139  List *pathkeys,
140  Path *fdw_outerpath,
141  List *fdw_private);
142 
143 extern Relids calc_nestloop_required_outer(Relids outerrelids,
144  Relids outer_paramrels,
145  Relids innerrelids,
146  Relids inner_paramrels);
147 extern Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path);
148 
150  RelOptInfo *joinrel,
151  JoinType jointype,
152  JoinCostWorkspace *workspace,
153  JoinPathExtraData *extra,
154  Path *outer_path,
155  Path *inner_path,
156  List *restrict_clauses,
157  List *pathkeys,
158  Relids required_outer);
159 
161  RelOptInfo *joinrel,
162  JoinType jointype,
163  JoinCostWorkspace *workspace,
164  JoinPathExtraData *extra,
165  Path *outer_path,
166  Path *inner_path,
167  List *restrict_clauses,
168  List *pathkeys,
169  Relids required_outer,
170  List *mergeclauses,
171  List *outersortkeys,
172  List *innersortkeys);
173 
175  RelOptInfo *joinrel,
176  JoinType jointype,
177  JoinCostWorkspace *workspace,
178  JoinPathExtraData *extra,
179  Path *outer_path,
180  Path *inner_path,
181  bool parallel_hash,
182  List *restrict_clauses,
183  Relids required_outer,
184  List *hashclauses);
185 
187  RelOptInfo *rel,
188  Path *subpath,
189  PathTarget *target);
191  RelOptInfo *rel,
192  Path *path,
193  PathTarget *target);
195  RelOptInfo *rel,
196  Path *subpath,
197  PathTarget *target);
199  RelOptInfo *rel,
200  Path *subpath,
201  List *pathkeys,
202  double limit_tuples);
204  RelOptInfo *rel,
205  Path *subpath,
206  List *pathkeys,
207  int presorted_keys,
208  double limit_tuples);
210  RelOptInfo *rel,
211  Path *subpath,
212  List *groupClause,
213  List *qual,
214  double numGroups);
216  RelOptInfo *rel,
217  Path *subpath,
218  int numCols,
219  double numGroups);
220 extern AggPath *create_agg_path(PlannerInfo *root,
221  RelOptInfo *rel,
222  Path *subpath,
223  PathTarget *target,
224  AggStrategy aggstrategy,
225  AggSplit aggsplit,
226  List *groupClause,
227  List *qual,
228  const AggClauseCosts *aggcosts,
229  double numGroups);
231  RelOptInfo *rel,
232  Path *subpath,
233  List *having_qual,
234  AggStrategy aggstrategy,
235  List *rollups,
236  const AggClauseCosts *agg_costs,
237  double numGroups);
239  RelOptInfo *rel,
240  PathTarget *target,
241  List *mmaggregates,
242  List *quals);
244  RelOptInfo *rel,
245  Path *subpath,
246  PathTarget *target,
247  List *windowFuncs,
248  WindowClause *winclause,
249  List *qual,
250  bool topwindow);
252  RelOptInfo *rel,
253  Path *subpath,
254  SetOpCmd cmd,
255  SetOpStrategy strategy,
256  List *distinctList,
257  AttrNumber flagColIdx,
258  int firstFlag,
259  double numGroups,
260  double outputRows);
262  RelOptInfo *rel,
263  Path *leftpath,
264  Path *rightpath,
265  PathTarget *target,
266  List *distinctList,
267  int wtParam,
268  double numGroups);
270  Path *subpath, List *rowMarks, int epqParam);
272  RelOptInfo *rel,
273  Path *subpath,
274  CmdType operation, bool canSetTag,
275  Index nominalRelation, Index rootRelation,
276  bool partColsUpdated,
277  List *resultRelations,
278  List *updateColnosLists,
279  List *withCheckOptionLists, List *returningLists,
280  List *rowMarks, OnConflictExpr *onconflict,
281  List *mergeActionLists, int epqParam);
283  Path *subpath,
284  Node *limitOffset, Node *limitCount,
285  LimitOption limitOption,
286  int64 offset_est, int64 count_est);
287 extern void adjust_limit_rows_costs(double *rows,
288  Cost *startup_cost, Cost *total_cost,
289  int64 offset_est, int64 count_est);
290 
291 extern Path *reparameterize_path(PlannerInfo *root, Path *path,
292  Relids required_outer,
293  double loop_count);
295  RelOptInfo *child_rel);
296 
297 /*
298  * prototypes for relnode.c
299  */
300 extern void setup_simple_rel_arrays(PlannerInfo *root);
301 extern void expand_planner_arrays(PlannerInfo *root, int add_size);
302 extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid,
303  RelOptInfo *parent);
304 extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid);
305 extern RelOptInfo *find_join_rel(PlannerInfo *root, Relids relids);
307  Relids joinrelids,
308  RelOptInfo *outer_rel,
309  RelOptInfo *inner_rel,
310  SpecialJoinInfo *sjinfo,
311  List **restrictlist_ptr);
313  Relids joinrelids,
314  RelOptInfo *outer_rel,
315  RelOptInfo *inner_rel);
317  Relids relids);
320  RelOptInfo *baserel,
321  Relids required_outer);
323  RelOptInfo *joinrel,
324  Path *outer_path,
325  Path *inner_path,
326  SpecialJoinInfo *sjinfo,
327  Relids required_outer,
328  List **restrict_clauses);
330  Relids required_outer);
332  Relids required_outer);
334  RelOptInfo *outer_rel, RelOptInfo *inner_rel,
335  RelOptInfo *parent_joinrel, List *restrictlist,
336  SpecialJoinInfo *sjinfo, JoinType jointype);
337 
338 #endif /* PATHNODE_H */
int16 AttrNumber
Definition: attnum.h:21
unsigned int Index
Definition: c.h:549
Datum subpath(PG_FUNCTION_ARGS)
Definition: ltree_op.c:241
SetOpCmd
Definition: nodes.h:850
SetOpStrategy
Definition: nodes.h:858
double Cost
Definition: nodes.h:707
CmdType
Definition: nodes.h:719
AggStrategy
Definition: nodes.h:806
AggSplit
Definition: nodes.h:828
LimitOption
Definition: nodes.h:883
JoinType
Definition: nodes.h:744
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_private)
Definition: pathnode.c:2301
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:83
SortPath * create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, double limit_tuples)
Definition: pathnode.c:2942
TidPath * create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, List *tidquals, Relids required_outer)
Definition: pathnode.c:1183
ParamPathInfo * get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, Relids required_outer)
Definition: relnode.c:1297
GroupResultPath * create_group_result_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *havingqual)
Definition: pathnode.c:1504
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:2407
Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path)
Definition: pathnode.c:2374
UniquePath * create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, SpecialJoinInfo *sjinfo)
Definition: pathnode.c:1640
WindowAggPath * create_windowagg_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *windowFuncs, WindowClause *winclause, List *qual, bool topwindow)
Definition: pathnode.c:3400
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:997
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:3736
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_private)
Definition: pathnode.c:2207
ProjectionPath * create_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2627
GatherMergePath * create_gather_merge_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *pathkeys, Relids required_outer, double *rows)
Definition: pathnode.c:1861
UpperUniquePath * create_upper_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, int numCols, double numGroups)
Definition: pathnode.c:3045
Relids calc_nestloop_required_outer(Relids outerrelids, Relids outer_paramrels, Relids innerrelids, Relids inner_paramrels)
Definition: pathnode.c:2341
GroupingSetsPath * create_groupingsets_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *having_qual, AggStrategy aggstrategy, List *rollups, const AggClauseCosts *agg_costs, double numGroups)
Definition: pathnode.c:3164
Path * create_tablefuncscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2045
Path * create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2122
Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
Definition: relnode.c:931
LockRowsPath * create_lockrows_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *rowMarks, int epqParam)
Definition: pathnode.c:3576
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
Definition: relnode.c:375
ParamPathInfo * get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
Definition: relnode.c:1594
RelOptInfo * build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
Definition: relnode.c:194
Path * reparameterize_path_by_child(PlannerInfo *root, Path *path, RelOptInfo *child_rel)
Definition: pathnode.c:3988
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:2495
GatherPath * create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, Relids required_outer, double *rows)
Definition: pathnode.c:1952
Path * create_resultscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2148
Path * create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:954
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:1584
MergeAppendPath * create_merge_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *pathkeys, Relids required_outer)
Definition: pathnode.c:1404
void set_cheapest(RelOptInfo *parent_rel)
Definition: pathnode.c:244
Relids find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
Definition: relnode.c:1261
Path * reparameterize_path(PlannerInfo *root, Path *path, Relids required_outer, double loop_count)
Definition: pathnode.c:3859
void expand_planner_arrays(PlannerInfo *root, int add_size)
Definition: relnode.c:152
ProjectSetPath * create_set_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2824
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
Definition: relnode.c:439
Path * create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2097
void add_partial_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:749
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:1387
MaterialPath * create_material_path(RelOptInfo *rel, Path *subpath)
Definition: pathnode.c:1552
Path * create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2019
BitmapOrPath * create_bitmap_or_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals)
Definition: pathnode.c:1131
int compare_fractional_path_costs(Path *path1, Path *path2, double fraction)
Definition: pathnode.c:117
GroupPath * create_group_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *groupClause, List *qual, double numGroups)
Definition: pathnode.c:2986
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_private)
Definition: pathnode.c:2251
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:2561
bool add_partial_path_precheck(RelOptInfo *parent_rel, Cost total_cost, List *pathkeys)
Definition: pathnode.c:867
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:3469
SubqueryScanPath * create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, Relids required_outer)
Definition: pathnode.c:1991
RelOptInfo * build_join_rel(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List **restrictlist_ptr)
Definition: relnode.c:577
RecursiveUnionPath * create_recursiveunion_path(PlannerInfo *root, RelOptInfo *rel, Path *leftpath, Path *rightpath, PathTarget *target, List *distinctList, int wtParam, double numGroups)
Definition: pathnode.c:3531
IncrementalSortPath * create_incremental_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, int presorted_keys, double limit_tuples)
Definition: pathnode.c:2893
MinMaxAggPath * create_minmaxagg_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *mmaggregates, List *quals)
Definition: pathnode.c:3325
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, int epqParam)
Definition: pathnode.c:3637
Path * create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2174
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:3097
void add_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:422
Path * create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2071
int compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
Definition: pathnode.c:71
ParamPathInfo * find_param_path_info(RelOptInfo *rel, Relids required_outer)
Definition: relnode.c:1626
Path * apply_projection_to_path(PlannerInfo *root, RelOptInfo *rel, Path *path, PathTarget *target)
Definition: pathnode.c:2735
BitmapAndPath * create_bitmap_and_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals)
Definition: pathnode.c:1079
TidRangePath * create_tidrangescan_path(PlannerInfo *root, RelOptInfo *rel, List *tidrangequals, Relids required_outer)
Definition: pathnode.c:1212
Path * create_seqscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer, int parallel_workers)
Definition: pathnode.c:929
void adjust_limit_rows_costs(double *rows, Cost *startup_cost, Cost *total_cost, int64 offset_est, int64 count_est)
Definition: pathnode.c:3791
RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
Definition: relnode.c:1210
RelOptInfo * build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel, RelOptInfo *parent_joinrel, List *restrictlist, SpecialJoinInfo *sjinfo, JoinType jointype)
Definition: relnode.c:786
bool add_path_precheck(RelOptInfo *parent_rel, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer)
Definition: pathnode.c:644
BitmapHeapPath * create_bitmap_heap_path(PlannerInfo *root, RelOptInfo *rel, Path *bitmapqual, Relids required_outer, double loop_count, int parallel_degree)
Definition: pathnode.c:1046
CostSelector
Definition: pathnodes.h:35
UpperRelationKind
Definition: pathnodes.h:68
ScanDirection
Definition: sdir.h:23
Size add_size(Size s1, Size s2)
Definition: shmem.c:502
Definition: pg_list.h:51
Definition: nodes.h:574
Definition: type.h:90