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-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
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, int disabled_nodes,
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  int disabled_nodes,
36  Cost total_cost, List *pathkeys);
37 
39  Relids required_outer, int parallel_workers);
41  Relids required_outer);
44  List *indexclauses,
45  List *indexorderbys,
46  List *indexorderbycols,
47  List *pathkeys,
48  ScanDirection indexscandir,
49  bool indexonly,
50  Relids required_outer,
51  double loop_count,
52  bool partial_path);
54  RelOptInfo *rel,
55  Path *bitmapqual,
56  Relids required_outer,
57  double loop_count,
58  int parallel_degree);
60  RelOptInfo *rel,
61  List *bitmapquals);
63  RelOptInfo *rel,
64  List *bitmapquals);
66  List *tidquals, Relids required_outer);
68  RelOptInfo *rel,
69  List *tidrangequals,
70  Relids required_outer);
72  List *subpaths, List *partial_subpaths,
73  List *pathkeys, Relids required_outer,
74  int parallel_workers, bool parallel_aware,
75  double rows);
77  RelOptInfo *rel,
78  List *subpaths,
79  List *pathkeys,
80  Relids required_outer);
82  RelOptInfo *rel,
83  PathTarget *target,
84  List *havingqual);
87  RelOptInfo *rel,
88  Path *subpath,
89  List *param_exprs,
90  List *hash_operators,
91  bool singlerow,
92  bool binary_mode,
93  double calls);
95  Path *subpath, SpecialJoinInfo *sjinfo);
97  RelOptInfo *rel, Path *subpath, PathTarget *target,
98  Relids required_outer, double *rows);
100  RelOptInfo *rel,
101  Path *subpath,
102  PathTarget *target,
103  List *pathkeys,
104  Relids required_outer,
105  double *rows);
107  RelOptInfo *rel,
108  Path *subpath,
109  bool trivial_pathtarget,
110  List *pathkeys,
111  Relids required_outer);
113  List *pathkeys, Relids required_outer);
115  Relids required_outer);
117  Relids required_outer);
119  List *pathkeys, Relids required_outer);
121  Relids required_outer);
123  Relids required_outer);
125  Relids required_outer);
127  PathTarget *target,
128  double rows, int disabled_nodes,
129  Cost startup_cost, Cost total_cost,
130  List *pathkeys,
131  Relids required_outer,
132  Path *fdw_outerpath,
133  List *fdw_restrictinfo,
134  List *fdw_private);
136  PathTarget *target,
137  double rows, int disabled_nodes,
138  Cost startup_cost, Cost total_cost,
139  List *pathkeys,
140  Relids required_outer,
141  Path *fdw_outerpath,
142  List *fdw_restrictinfo,
143  List *fdw_private);
145  PathTarget *target,
146  double rows, int disabled_nodes,
147  Cost startup_cost, Cost total_cost,
148  List *pathkeys,
149  Path *fdw_outerpath,
150  List *fdw_restrictinfo,
151  List *fdw_private);
152 
153 extern Relids calc_nestloop_required_outer(Relids outerrelids,
154  Relids outer_paramrels,
155  Relids innerrelids,
156  Relids inner_paramrels);
157 extern Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path);
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 
171  RelOptInfo *joinrel,
172  JoinType jointype,
173  JoinCostWorkspace *workspace,
174  JoinPathExtraData *extra,
175  Path *outer_path,
176  Path *inner_path,
177  List *restrict_clauses,
178  List *pathkeys,
179  Relids required_outer,
180  List *mergeclauses,
181  List *outersortkeys,
182  List *innersortkeys);
183 
185  RelOptInfo *joinrel,
186  JoinType jointype,
187  JoinCostWorkspace *workspace,
188  JoinPathExtraData *extra,
189  Path *outer_path,
190  Path *inner_path,
191  bool parallel_hash,
192  List *restrict_clauses,
193  Relids required_outer,
194  List *hashclauses);
195 
197  RelOptInfo *rel,
198  Path *subpath,
199  PathTarget *target);
201  RelOptInfo *rel,
202  Path *path,
203  PathTarget *target);
205  RelOptInfo *rel,
206  Path *subpath,
207  PathTarget *target);
209  RelOptInfo *rel,
210  Path *subpath,
211  List *pathkeys,
212  double limit_tuples);
214  RelOptInfo *rel,
215  Path *subpath,
216  List *pathkeys,
217  int presorted_keys,
218  double limit_tuples);
220  RelOptInfo *rel,
221  Path *subpath,
222  List *groupClause,
223  List *qual,
224  double numGroups);
226  RelOptInfo *rel,
227  Path *subpath,
228  int numCols,
229  double numGroups);
231  RelOptInfo *rel,
232  Path *subpath,
233  PathTarget *target,
234  AggStrategy aggstrategy,
235  AggSplit aggsplit,
236  List *groupClause,
237  List *qual,
238  const AggClauseCosts *aggcosts,
239  double numGroups);
241  RelOptInfo *rel,
242  Path *subpath,
243  List *having_qual,
244  AggStrategy aggstrategy,
245  List *rollups,
246  const AggClauseCosts *agg_costs);
248  RelOptInfo *rel,
249  PathTarget *target,
250  List *mmaggregates,
251  List *quals);
253  RelOptInfo *rel,
254  Path *subpath,
255  PathTarget *target,
256  List *windowFuncs,
257  List *runCondition,
258  WindowClause *winclause,
259  List *qual,
260  bool topwindow);
262  RelOptInfo *rel,
263  Path *subpath,
264  SetOpCmd cmd,
265  SetOpStrategy strategy,
266  List *distinctList,
267  AttrNumber flagColIdx,
268  int firstFlag,
269  double numGroups,
270  double outputRows);
272  RelOptInfo *rel,
273  Path *leftpath,
274  Path *rightpath,
275  PathTarget *target,
276  List *distinctList,
277  int wtParam,
278  double numGroups);
280  Path *subpath, List *rowMarks, int epqParam);
282  RelOptInfo *rel,
283  Path *subpath,
284  CmdType operation, bool canSetTag,
285  Index nominalRelation, Index rootRelation,
286  bool partColsUpdated,
287  List *resultRelations,
288  List *updateColnosLists,
289  List *withCheckOptionLists, List *returningLists,
290  List *rowMarks, OnConflictExpr *onconflict,
291  List *mergeActionLists, List *mergeJoinConditions,
292  int epqParam);
294  Path *subpath,
295  Node *limitOffset, Node *limitCount,
296  LimitOption limitOption,
297  int64 offset_est, int64 count_est);
298 extern void adjust_limit_rows_costs(double *rows,
299  Cost *startup_cost, Cost *total_cost,
300  int64 offset_est, int64 count_est);
301 
303  Relids required_outer,
304  double loop_count);
306  RelOptInfo *child_rel);
307 extern bool path_is_reparameterizable_by_child(Path *path,
308  RelOptInfo *child_rel);
309 
310 /*
311  * prototypes for relnode.c
312  */
315 extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid,
316  RelOptInfo *parent);
317 extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid);
318 extern RelOptInfo *find_base_rel_noerr(PlannerInfo *root, int relid);
322  Relids joinrelids,
323  RelOptInfo *outer_rel,
324  RelOptInfo *inner_rel,
325  SpecialJoinInfo *sjinfo,
326  List *pushed_down_joins,
327  List **restrictlist_ptr);
329  Relids joinrelids,
330  RelOptInfo *outer_rel,
331  RelOptInfo *inner_rel);
333  Relids relids);
336  RelOptInfo *baserel,
337  Relids required_outer);
339  RelOptInfo *joinrel,
340  Path *outer_path,
341  Path *inner_path,
342  SpecialJoinInfo *sjinfo,
343  Relids required_outer,
344  List **restrict_clauses);
346  Relids required_outer);
348  Relids required_outer);
351  RelOptInfo *outer_rel, RelOptInfo *inner_rel,
352  RelOptInfo *parent_joinrel, List *restrictlist,
353  SpecialJoinInfo *sjinfo,
354  int nappinfos, AppendRelInfo **appinfos);
355 
356 #endif /* PATHNODE_H */
int16 AttrNumber
Definition: attnum.h:21
unsigned int Index
Definition: c.h:605
Datum subpath(PG_FUNCTION_ARGS)
Definition: ltree_op.c:310
SetOpCmd
Definition: nodes.h:397
SetOpStrategy
Definition: nodes.h:405
double Cost
Definition: nodes.h:251
CmdType
Definition: nodes.h:263
AggStrategy
Definition: nodes.h:353
AggSplit
Definition: nodes.h:375
LimitOption
Definition: nodes.h:430
JoinType
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:1300
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:3082
TidPath * create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, List *tidquals, Relids required_outer)
Definition: pathnode.c:1235
ParamPathInfo * get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, Relids required_outer)
Definition: relnode.c:1545
GroupResultPath * create_group_result_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *havingqual)
Definition: pathnode.c:1586
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:2535
Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path)
Definition: pathnode.c:2483
UniquePath * create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, SpecialJoinInfo *sjinfo)
Definition: pathnode.c:1727
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:4508
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:1049
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:3922
ProjectionPath * create_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2763
GatherMergePath * create_gather_merge_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *pathkeys, Relids required_outer, double *rows)
Definition: pathnode.c:1962
UpperUniquePath * create_upper_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, int numCols, double numGroups)
Definition: pathnode.c:3187
Relids calc_nestloop_required_outer(Relids outerrelids, Relids outer_paramrels, Relids innerrelids, Relids inner_paramrels)
Definition: pathnode.c:2456
Path * create_tablefuncscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2144
Path * create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2222
Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
Definition: relnode.c:1022
RelOptInfo * build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel, RelOptInfo *parent_joinrel, List *restrictlist, SpecialJoinInfo *sjinfo, int nappinfos, AppendRelInfo **appinfos)
Definition: relnode.c:882
ForeignPath * create_foreign_join_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, int disabled_nodes, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
Definition: pathnode.c:2355
LockRowsPath * create_lockrows_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *rowMarks, int epqParam)
Definition: pathnode.c:3756
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
Definition: relnode.c:414
ParamPathInfo * get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
Definition: relnode.c:1856
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:4212
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:2631
GatherPath * create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, Relids required_outer, double *rows)
Definition: pathnode.c:2044
Path * create_resultscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2248
Path * create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:1008
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:1667
MergeAppendPath * create_merge_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *pathkeys, Relids required_outer)
Definition: pathnode.c:1471
void set_cheapest(RelOptInfo *parent_rel)
Definition: pathnode.c:269
Relids find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
Definition: relnode.c:1509
Path * reparameterize_path(PlannerInfo *root, Path *path, Relids required_outer, double loop_count)
Definition: pathnode.c:4046
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:2962
SubqueryScanPath * create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, bool trivial_pathtarget, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2088
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
Definition: relnode.c:527
void add_partial_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:795
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:1659
MaterialPath * create_material_path(RelOptInfo *rel, Path *subpath)
Definition: pathnode.c:1634
Path * create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2118
BitmapOrPath * create_bitmap_or_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals)
Definition: pathnode.c:1183
int compare_fractional_path_costs(Path *path1, Path *path2, double fraction)
Definition: pathnode.c:124
GroupPath * create_group_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *groupClause, List *qual, double numGroups)
Definition: pathnode.c:3127
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:2697
RelOptInfo * find_base_rel_noerr(PlannerInfo *root, int relid)
Definition: relnode.c:436
GroupingSetsPath * create_groupingsets_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *having_qual, AggStrategy aggstrategy, List *rollups, const AggClauseCosts *agg_costs)
Definition: pathnode.c:3323
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:3648
RecursiveUnionPath * create_recursiveunion_path(PlannerInfo *root, RelOptInfo *rel, Path *leftpath, Path *rightpath, PathTarget *target, List *distinctList, int wtParam, double numGroups)
Definition: pathnode.c:3711
IncrementalSortPath * create_incremental_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, int presorted_keys, double limit_tuples)
Definition: pathnode.c:3032
MinMaxAggPath * create_minmaxagg_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *mmaggregates, List *quals)
Definition: pathnode.c:3486
Path * create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2274
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:3577
ForeignPath * create_foreign_upper_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, int disabled_nodes, Cost startup_cost, Cost total_cost, List *pathkeys, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
Definition: pathnode.c:2409
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:3240
void add_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:461
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:3820
Path * create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2170
int compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
Definition: pathnode.c:69
bool add_path_precheck(RelOptInfo *parent_rel, int disabled_nodes, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer)
Definition: pathnode.c:688
ForeignPath * create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, int disabled_nodes, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
Definition: pathnode.c:2307
ParamPathInfo * find_param_path_info(RelOptInfo *rel, Relids required_outer)
Definition: relnode.c:1889
Path * apply_projection_to_path(PlannerInfo *root, RelOptInfo *rel, Path *path, PathTarget *target)
Definition: pathnode.c:2873
BitmapAndPath * create_bitmap_and_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals)
Definition: pathnode.c:1131
TidRangePath * create_tidrangescan_path(PlannerInfo *root, RelOptInfo *rel, List *tidrangequals, Relids required_outer)
Definition: pathnode.c:1264
Path * create_seqscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer, int parallel_workers)
Definition: pathnode.c:983
void adjust_limit_rows_costs(double *rows, Cost *startup_cost, Cost *total_cost, int64 offset_est, int64 count_est)
Definition: pathnode.c:3978
RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
Definition: relnode.c:1458
bool add_partial_path_precheck(RelOptInfo *parent_rel, int disabled_nodes, Cost total_cost, List *pathkeys)
Definition: pathnode.c:921
Bitmapset * get_param_path_clause_serials(Path *path)
Definition: relnode.c:1910
Path * create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
Definition: pathnode.c:2196
BitmapHeapPath * create_bitmap_heap_path(PlannerInfo *root, RelOptInfo *rel, Path *bitmapqual, Relids required_outer, double loop_count, int parallel_degree)
Definition: pathnode.c:1098
CostSelector
Definition: pathnodes.h:37
UpperRelationKind
Definition: pathnodes.h:70
tree ctl root
Definition: radixtree.h:1886
ScanDirection
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