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-2020, 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  List *subpaths, List *partial_subpaths,
68  List *pathkeys, Relids required_outer,
69  int parallel_workers, bool parallel_aware,
70  List *partitioned_rels, double rows);
72  RelOptInfo *rel,
73  List *subpaths,
74  List *pathkeys,
75  Relids required_outer,
76  List *partitioned_rels);
78  RelOptInfo *rel,
79  PathTarget *target,
80  List *havingqual);
83  Path *subpath, SpecialJoinInfo *sjinfo);
85  RelOptInfo *rel, Path *subpath, PathTarget *target,
86  Relids required_outer, double *rows);
88  RelOptInfo *rel,
89  Path *subpath,
90  PathTarget *target,
91  List *pathkeys,
92  Relids required_outer,
93  double *rows);
95  RelOptInfo *rel, Path *subpath,
96  List *pathkeys, Relids required_outer);
98  List *pathkeys, Relids required_outer);
100  Relids required_outer);
102  Relids required_outer);
103 extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel,
104  Relids required_outer);
106  Relids required_outer);
108  Relids required_outer);
110  Relids required_outer);
112  PathTarget *target,
113  double rows, Cost startup_cost, Cost total_cost,
114  List *pathkeys,
115  Relids required_outer,
116  Path *fdw_outerpath,
117  List *fdw_private);
119  PathTarget *target,
120  double rows, Cost startup_cost, Cost total_cost,
121  List *pathkeys,
122  Relids required_outer,
123  Path *fdw_outerpath,
124  List *fdw_private);
126  PathTarget *target,
127  double rows, Cost startup_cost, Cost total_cost,
128  List *pathkeys,
129  Path *fdw_outerpath,
130  List *fdw_private);
132 extern Relids calc_nestloop_required_outer(Relids outerrelids,
133  Relids outer_paramrels,
134  Relids innerrelids,
135  Relids inner_paramrels);
136 extern Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path);
139  RelOptInfo *joinrel,
140  JoinType jointype,
141  JoinCostWorkspace *workspace,
142  JoinPathExtraData *extra,
143  Path *outer_path,
144  Path *inner_path,
145  List *restrict_clauses,
146  List *pathkeys,
147  Relids required_outer);
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  List *mergeclauses,
160  List *outersortkeys,
161  List *innersortkeys);
164  RelOptInfo *joinrel,
165  JoinType jointype,
166  JoinCostWorkspace *workspace,
167  JoinPathExtraData *extra,
168  Path *outer_path,
169  Path *inner_path,
170  bool parallel_hash,
171  List *restrict_clauses,
172  Relids required_outer,
173  List *hashclauses);
176  RelOptInfo *rel,
177  Path *subpath,
178  PathTarget *target);
180  RelOptInfo *rel,
181  Path *path,
182  PathTarget *target);
184  RelOptInfo *rel,
185  Path *subpath,
186  PathTarget *target);
188  RelOptInfo *rel,
189  Path *subpath,
190  List *pathkeys,
191  double limit_tuples);
193  RelOptInfo *rel,
194  Path *subpath,
195  List *pathkeys,
196  int presorted_keys,
197  double limit_tuples);
199  RelOptInfo *rel,
200  Path *subpath,
201  List *groupClause,
202  List *qual,
203  double numGroups);
205  RelOptInfo *rel,
206  Path *subpath,
207  int numCols,
208  double numGroups);
209 extern AggPath *create_agg_path(PlannerInfo *root,
210  RelOptInfo *rel,
211  Path *subpath,
212  PathTarget *target,
213  AggStrategy aggstrategy,
214  AggSplit aggsplit,
215  List *groupClause,
216  List *qual,
217  const AggClauseCosts *aggcosts,
218  double numGroups);
220  RelOptInfo *rel,
221  Path *subpath,
222  List *having_qual,
223  AggStrategy aggstrategy,
224  List *rollups,
225  const AggClauseCosts *agg_costs,
226  double numGroups);
228  RelOptInfo *rel,
229  PathTarget *target,
230  List *mmaggregates,
231  List *quals);
233  RelOptInfo *rel,
234  Path *subpath,
235  PathTarget *target,
236  List *windowFuncs,
237  WindowClause *winclause);
239  RelOptInfo *rel,
240  Path *subpath,
241  SetOpCmd cmd,
242  SetOpStrategy strategy,
243  List *distinctList,
244  AttrNumber flagColIdx,
245  int firstFlag,
246  double numGroups,
247  double outputRows);
249  RelOptInfo *rel,
250  Path *leftpath,
251  Path *rightpath,
252  PathTarget *target,
253  List *distinctList,
254  int wtParam,
255  double numGroups);
257  Path *subpath, List *rowMarks, int epqParam);
259  RelOptInfo *rel,
260  CmdType operation, bool canSetTag,
261  Index nominalRelation, Index rootRelation,
262  bool partColsUpdated,
263  List *resultRelations, List *subpaths,
264  List *subroots,
265  List *withCheckOptionLists, List *returningLists,
266  List *rowMarks, OnConflictExpr *onconflict,
267  int epqParam);
269  Path *subpath,
270  Node *limitOffset, Node *limitCount,
271  LimitOption limitOption,
272  int64 offset_est, int64 count_est);
273 extern void adjust_limit_rows_costs(double *rows,
274  Cost *startup_cost, Cost *total_cost,
275  int64 offset_est, int64 count_est);
277 extern Path *reparameterize_path(PlannerInfo *root, Path *path,
278  Relids required_outer,
279  double loop_count);
281  RelOptInfo *child_rel);
283 /*
284  * prototypes for relnode.c
285  */
286 extern void setup_simple_rel_arrays(PlannerInfo *root);
287 extern void expand_planner_arrays(PlannerInfo *root, int add_size);
288 extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid,
289  RelOptInfo *parent);
290 extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid);
291 extern RelOptInfo *find_join_rel(PlannerInfo *root, Relids relids);
293  Relids joinrelids,
294  RelOptInfo *outer_rel,
295  RelOptInfo *inner_rel,
296  SpecialJoinInfo *sjinfo,
297  List **restrictlist_ptr);
299  Relids joinrelids,
300  RelOptInfo *outer_rel,
301  RelOptInfo *inner_rel);
303  Relids relids);
306  RelOptInfo *baserel,
307  Relids required_outer);
309  RelOptInfo *joinrel,
310  Path *outer_path,
311  Path *inner_path,
312  SpecialJoinInfo *sjinfo,
313  Relids required_outer,
314  List **restrict_clauses);
316  Relids required_outer);
318  Relids required_outer);
320  RelOptInfo *outer_rel, RelOptInfo *inner_rel,
321  RelOptInfo *parent_joinrel, List *restrictlist,
322  SpecialJoinInfo *sjinfo, JoinType jointype);
324 #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
void add_path(RelOptInfo *parent_rel, Path *new_path)
Definition: pathnode.c:422
void setup_simple_rel_arrays(PlannerInfo *root)
Definition: relnode.c:83
Definition: pathnodes.h:67
Path * reparameterize_path(PlannerInfo *root, Path *path, Relids required_outer, double loop_count)
Definition: pathnode.c:3761
ProjectSetPath * create_set_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2733
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:3367
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
Definition: relnode.c:438
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:3638
AppendPath * create_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *partial_subpaths, List *pathkeys, Relids required_outer, int parallel_workers, bool parallel_aware, List *partitioned_rels, double rows)
Definition: pathnode.c:1215
Definition: nodes.h:527
Path * create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2048
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:3006
IncrementalSortPath * create_incremental_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, int presorted_keys, double limit_tuples)
Definition: pathnode.c:2802
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
Definition: relnode.c:373
MaterialPath * create_material_path(RelOptInfo *rel, Path *subpath)
Definition: pathnode.c:1527
ParamPathInfo * get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
Definition: relnode.c:1573
void adjust_limit_rows_costs(double *rows, Cost *startup_cost, Cost *total_cost, int64 offset_est, int64 count_est)
Definition: pathnode.c:3693
Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
Definition: relnode.c:926
MergeAppendPath * create_merge_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *pathkeys, Relids required_outer, List *partitioned_rels)
Definition: pathnode.c:1377
Definition: nodes.h:808
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:2421
Definition: nodes.h:694
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:2895
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:2133
Definition: type.h:89
ParamPathInfo * get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, Relids required_outer)
Definition: relnode.c:1276
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:3429
UniquePath * create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, SpecialJoinInfo *sjinfo)
Definition: pathnode.c:1566
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:2023
Path * create_tablefuncscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:1971
Path * create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
Definition: pathnode.c:1945
Relids find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
Definition: relnode.c:1240
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:576
GroupResultPath * create_group_result_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *havingqual)
Definition: pathnode.c:1479
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:3474
ModifyTablePath * create_modifytable_path(PlannerInfo *root, RelOptInfo *rel, CmdType operation, bool canSetTag, Index nominalRelation, Index rootRelation, bool partColsUpdated, List *resultRelations, List *subpaths, List *subroots, List *withCheckOptionLists, List *returningLists, List *rowMarks, OnConflictExpr *onconflict, int epqParam)
Definition: pathnode.c:3533
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:2177
Path * reparameterize_path_by_child(PlannerInfo *root, Path *path, RelOptInfo *child_rel)
Definition: pathnode.c:3879
Path * create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:954
bool canSetTag
Definition: plannodes.h:54
Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path)
Definition: pathnode.c:2300
GatherMergePath * create_gather_merge_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *pathkeys, Relids required_outer, double *rows)
Definition: pathnode.c:1787
Size add_size(Size s1, Size s2)
Definition: shmem.c:498
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:2227
WindowAggPath * create_windowagg_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *windowFuncs, WindowClause *winclause)
Definition: pathnode.c:3305
unsigned int Index
Definition: c.h:537
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:2333
Definition: pathnodes.h:34
Path * create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2100
Relids calc_nestloop_required_outer(Relids outerrelids, Relids outer_paramrels, Relids innerrelids, Relids inner_paramrels)
Definition: pathnode.c:2267
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:3073
Path * create_resultscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Definition: pathnode.c:2074
Definition: nodes.h:778
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:783
Definition: nodes.h:833
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:1366
ProjectionPath * create_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Definition: pathnode.c:2553
SortPath * create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, double limit_tuples)
Definition: pathnode.c:2851
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:2487
GatherPath * create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, Relids required_outer, double *rows)
Definition: pathnode.c:1878
Definition: nodes.h:756
Definition: nodes.h:800
List * resultRelations
Definition: plannodes.h:69
SubqueryScanPath * create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, Relids required_outer)
Definition: pathnode.c:1917
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:1189
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:1605
UpperUniquePath * create_upper_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, int numCols, double numGroups)
Definition: pathnode.c:2954
MinMaxAggPath * create_minmaxagg_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *mmaggregates, List *quals)
Definition: pathnode.c:3234
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:1997
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:2644
Definition: nodes.h:670
double Cost
Definition: nodes.h:661
Datum subpath(PG_FUNCTION_ARGS)
Definition: ltree_op.c:241