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-2021, 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  double calls);
93  Path *subpath, SpecialJoinInfo *sjinfo);
95  RelOptInfo *rel, Path *subpath, PathTarget *target,
96  Relids required_outer, double *rows);
98  RelOptInfo *rel,
99  Path *subpath,
100  PathTarget *target,
101  List *pathkeys,
102  Relids required_outer,
103  double *rows);
105  RelOptInfo *rel, Path *subpath,
106  List *pathkeys, Relids required_outer);
108  List *pathkeys, Relids required_outer);
110  Relids required_outer);
112  Relids required_outer);
113 extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel,
114  Relids required_outer);
116  Relids required_outer);
118  Relids required_outer);
120  Relids required_outer);
122  PathTarget *target,
123  double rows, Cost startup_cost, Cost total_cost,
124  List *pathkeys,
125  Relids required_outer,
126  Path *fdw_outerpath,
127  List *fdw_private);
129  PathTarget *target,
130  double rows, Cost startup_cost, Cost total_cost,
131  List *pathkeys,
132  Relids required_outer,
133  Path *fdw_outerpath,
134  List *fdw_private);
136  PathTarget *target,
137  double rows, Cost startup_cost, Cost total_cost,
138  List *pathkeys,
139  Path *fdw_outerpath,
140  List *fdw_private);
141 
142 extern Relids calc_nestloop_required_outer(Relids outerrelids,
143  Relids outer_paramrels,
144  Relids innerrelids,
145  Relids inner_paramrels);
146 extern Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path);
147 
149  RelOptInfo *joinrel,
150  JoinType jointype,
151  JoinCostWorkspace *workspace,
152  JoinPathExtraData *extra,
153  Path *outer_path,
154  Path *inner_path,
155  List *restrict_clauses,
156  List *pathkeys,
157  Relids required_outer);
158 
160  RelOptInfo *joinrel,
161  JoinType jointype,
162  JoinCostWorkspace *workspace,
163  JoinPathExtraData *extra,
164  Path *outer_path,
165  Path *inner_path,
166  List *restrict_clauses,
167  List *pathkeys,
168  Relids required_outer,
169  List *mergeclauses,
170  List *outersortkeys,
171  List *innersortkeys);
172 
174  RelOptInfo *joinrel,
175  JoinType jointype,
176  JoinCostWorkspace *workspace,
177  JoinPathExtraData *extra,
178  Path *outer_path,
179  Path *inner_path,
180  bool parallel_hash,
181  List *restrict_clauses,
182  Relids required_outer,
183  List *hashclauses);
184 
186  RelOptInfo *rel,
187  Path *subpath,
188  PathTarget *target);
190  RelOptInfo *rel,
191  Path *path,
192  PathTarget *target);
194  RelOptInfo *rel,
195  Path *subpath,
196  PathTarget *target);
198  RelOptInfo *rel,
199  Path *subpath,
200  List *pathkeys,
201  double limit_tuples);
203  RelOptInfo *rel,
204  Path *subpath,
205  List *pathkeys,
206  int presorted_keys,
207  double limit_tuples);
209  RelOptInfo *rel,
210  Path *subpath,
211  List *groupClause,
212  List *qual,
213  double numGroups);
215  RelOptInfo *rel,
216  Path *subpath,
217  int numCols,
218  double numGroups);
219 extern AggPath *create_agg_path(PlannerInfo *root,
220  RelOptInfo *rel,
221  Path *subpath,
222  PathTarget *target,
223  AggStrategy aggstrategy,
224  AggSplit aggsplit,
225  List *groupClause,
226  List *qual,
227  const AggClauseCosts *aggcosts,
228  double numGroups);
230  RelOptInfo *rel,
231  Path *subpath,
232  List *having_qual,
233  AggStrategy aggstrategy,
234  List *rollups,
235  const AggClauseCosts *agg_costs,
236  double numGroups);
238  RelOptInfo *rel,
239  PathTarget *target,
240  List *mmaggregates,
241  List *quals);
243  RelOptInfo *rel,
244  Path *subpath,
245  PathTarget *target,
246  List *windowFuncs,
247  WindowClause *winclause);
249  RelOptInfo *rel,
250  Path *subpath,
251  SetOpCmd cmd,
252  SetOpStrategy strategy,
253  List *distinctList,
254  AttrNumber flagColIdx,
255  int firstFlag,
256  double numGroups,
257  double outputRows);
259  RelOptInfo *rel,
260  Path *leftpath,
261  Path *rightpath,
262  PathTarget *target,
263  List *distinctList,
264  int wtParam,
265  double numGroups);
267  Path *subpath, List *rowMarks, int epqParam);
269  RelOptInfo *rel,
270  Path *subpath,
271  CmdType operation, bool canSetTag,
272  Index nominalRelation, Index rootRelation,
273  bool partColsUpdated,
275  List *updateColnosLists,
276  List *withCheckOptionLists, List *returningLists,
277  List *rowMarks, OnConflictExpr *onconflict,
278  int epqParam);
280  Path *subpath,
281  Node *limitOffset, Node *limitCount,
282  LimitOption limitOption,
283  int64 offset_est, int64 count_est);
284 extern void adjust_limit_rows_costs(double *rows,
285  Cost *startup_cost, Cost *total_cost,
286  int64 offset_est, int64 count_est);
287 
288 extern Path *reparameterize_path(PlannerInfo *root, Path *path,
289  Relids required_outer,
290  double loop_count);
292  RelOptInfo *child_rel);
293 
294 /*
295  * prototypes for relnode.c
296  */
297 extern void setup_simple_rel_arrays(PlannerInfo *root);
298 extern void expand_planner_arrays(PlannerInfo *root, int add_size);
299 extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid,
300  RelOptInfo *parent);
301 extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid);
302 extern RelOptInfo *find_join_rel(PlannerInfo *root, Relids relids);
304  Relids joinrelids,
305  RelOptInfo *outer_rel,
306  RelOptInfo *inner_rel,
307  SpecialJoinInfo *sjinfo,
308  List **restrictlist_ptr);
310  Relids joinrelids,
311  RelOptInfo *outer_rel,
312  RelOptInfo *inner_rel);
314  Relids relids);
317  RelOptInfo *baserel,
318  Relids required_outer);
320  RelOptInfo *joinrel,
321  Path *outer_path,
322  Path *inner_path,
323  SpecialJoinInfo *sjinfo,
324  Relids required_outer,
325  List **restrict_clauses);
327  Relids required_outer);
329  Relids required_outer);
331  RelOptInfo *outer_rel, RelOptInfo *inner_rel,
332  RelOptInfo *parent_joinrel, List *restrictlist,
333  SpecialJoinInfo *sjinfo, JoinType jointype);
334 
335 #endif /* PATHNODE_H */
Path * create_seqscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer, int parallel_workers)
Definition: pathnode.c:929
bool add_path_precheck(RelOptInfo *parent_rel, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer)
Definition: pathnode.c:644
TidRangePath * create_tidrangescan_path(PlannerInfo *root, RelOptInfo *rel, List *tidrangequals, Relids required_outer)
Definition: pathnode.c:1212
void add_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:422
void setup_simple_rel_arrays(PlannerInfo *root)
Definition: relnode.c:83
UpperRelationKind
Definition: pathnodes.h:67
Path * reparameterize_path(PlannerInfo *root, Path *path, Relids required_outer, double loop_count)
Definition: pathnode.c:3844
ProjectSetPath * create_set_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2823
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:3457
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
Definition: relnode.c:439
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:3721
Definition: nodes.h:536
Path * create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2121
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:3096
IncrementalSortPath * create_incremental_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, int presorted_keys, double limit_tuples)
Definition: pathnode.c:2892
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
Definition: relnode.c:375
MaterialPath * create_material_path(RelOptInfo *rel, Path *subpath)
Definition: pathnode.c:1552
MemoizePath * create_memoize_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *param_exprs, List *hash_operators, bool singlerow, double calls)
Definition: pathnode.c:1584
ParamPathInfo * get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
Definition: relnode.c:1594
void adjust_limit_rows_costs(double *rows, Cost *startup_cost, Cost *total_cost, int64 offset_est, int64 count_est)
Definition: pathnode.c:3776
Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
Definition: relnode.c:931
SetOpStrategy
Definition: nodes.h:818
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:2494
JoinType
Definition: nodes.h:704
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:2985
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:2206
Definition: type.h:89
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, int epqParam)
Definition: pathnode.c:3624
ParamPathInfo * get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, Relids required_outer)
Definition: relnode.c:1297
bool add_partial_path_precheck(RelOptInfo *parent_rel, Cost total_cost, List *pathkeys)
Definition: pathnode.c:867
RecursiveUnionPath * create_recursiveunion_path(PlannerInfo *root, RelOptInfo *rel, Path *leftpath, Path *rightpath, PathTarget *target, List *distinctList, int wtParam, double numGroups)
Definition: pathnode.c:3519
UniquePath * create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, SpecialJoinInfo *sjinfo)
Definition: pathnode.c:1639
int compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
Definition: pathnode.c:71
Path * create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2096
Path * create_tablefuncscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2044
Path * create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2018
Relids find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
Definition: relnode.c:1261
RelOptInfo * build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
Definition: relnode.c:194
void set_cheapest(RelOptInfo *parent_rel)
Definition: pathnode.c:244
BitmapAndPath * create_bitmap_and_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals)
Definition: pathnode.c:1079
RelOptInfo * build_join_rel(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List **restrictlist_ptr)
Definition: relnode.c:577
GroupResultPath * create_group_result_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *havingqual)
Definition: pathnode.c:1504
ScanDirection
Definition: sdir.h:22
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
LockRowsPath * create_lockrows_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *rowMarks, int epqParam)
Definition: pathnode.c:3564
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:2250
Path * reparameterize_path_by_child(PlannerInfo *root, Path *path, RelOptInfo *child_rel)
Definition: pathnode.c:3972
Path * create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:954
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
bool canSetTag
Definition: plannodes.h:54
Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path)
Definition: pathnode.c:2373
GatherMergePath * create_gather_merge_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *pathkeys, Relids required_outer, double *rows)
Definition: pathnode.c:1860
Size add_size(Size s1, Size s2)
Definition: shmem.c:502
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:2300
WindowAggPath * create_windowagg_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *windowFuncs, WindowClause *winclause)
Definition: pathnode.c:3395
unsigned int Index
Definition: c.h:549
List * rowMarks
Definition: plannodes.h:78
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:2406
CostSelector
Definition: pathnodes.h:34
Path * create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2173
MergeAppendPath * create_merge_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *pathkeys, Relids required_outer)
Definition: pathnode.c:1404
Relids calc_nestloop_required_outer(Relids outerrelids, Relids outer_paramrels, Relids innerrelids, Relids inner_paramrels)
Definition: pathnode.c:2340
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:3163
Path * create_resultscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2147
AggSplit
Definition: nodes.h:788
BitmapHeapPath * create_bitmap_heap_path(PlannerInfo *root, RelOptInfo *rel, Path *bitmapqual, Relids required_outer, double loop_count, int parallel_degree)
Definition: pathnode.c:1046
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
LimitOption
Definition: nodes.h:843
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
ProjectionPath * create_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2626
SortPath * create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, double limit_tuples)
Definition: pathnode.c:2941
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:2560
GatherPath * create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, Relids required_outer, double *rows)
Definition: pathnode.c:1951
AggStrategy
Definition: nodes.h:766
SetOpCmd
Definition: nodes.h:810
List * resultRelations
Definition: plannodes.h:69
SubqueryScanPath * create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, Relids required_outer)
Definition: pathnode.c:1990
TidPath * create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, List *tidquals, Relids required_outer)
Definition: pathnode.c:1183
RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
Definition: relnode.c:1210
void add_partial_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:749
ParamPathInfo * find_param_path_info(RelOptInfo *rel, Relids required_outer)
Definition: relnode.c:1626
UpperUniquePath * create_upper_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, int numCols, double numGroups)
Definition: pathnode.c:3044
MinMaxAggPath * create_minmaxagg_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *mmaggregates, List *quals)
Definition: pathnode.c:3324
void expand_planner_arrays(PlannerInfo *root, int add_size)
Definition: relnode.c:152
Path * create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2070
Definition: pg_list.h:50
int16 AttrNumber
Definition: attnum.h:21
BitmapOrPath * create_bitmap_or_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals)
Definition: pathnode.c:1131
Path * apply_projection_to_path(PlannerInfo *root, RelOptInfo *rel, Path *path, PathTarget *target)
Definition: pathnode.c:2734
CmdType
Definition: nodes.h:680
double Cost
Definition: nodes.h:670
Datum subpath(PG_FUNCTION_ARGS)
Definition: ltree_op.c:241