31 #ifdef OPTIMIZER_DEBUG
56 #define UNSAFE_HAS_VOLATILE_FUNC (1 << 0)
57 #define UNSAFE_HAS_SET_FUNC (1 << 1)
58 #define UNSAFE_NOTIN_DISTINCTON_CLAUSE (1 << 2)
59 #define UNSAFE_NOTIN_PARTITIONBY_CLAUSE (1 << 3)
60 #define UNSAFE_TYPE_MISMATCH (1 << 4)
121 List *live_childrels,
122 List *all_child_pathkeys);
128 List **special_subpaths);
205 RelOptInfo *brel = root->simple_rel_array[rti];
217 total_pages += (double) brel->
pages;
299 RelOptInfo *rel = root->simple_rel_array[rti];
312 rte = root->simple_rte_array[rti];
342 RelOptInfo *rel = root->simple_rel_array[rti];
392 if (rte->
relkind == RELKIND_FOREIGN_TABLE)
397 else if (rte->
relkind == RELKIND_PARTITIONED_TABLE)
489 if (rte->
relkind == RELKIND_FOREIGN_TABLE)
542 (*set_rel_pathlist_hook) (root, rel, rti, rte);
565 #ifdef OPTIMIZER_DEBUG
633 if (proparallel != PROPARALLEL_SAFE)
647 if (rte->
relkind == RELKIND_FOREIGN_TABLE)
650 if (!rel->fdwroutine->IsForeignScanParallelSafe)
652 if (!rel->fdwroutine->IsForeignScanParallelSafe(root, rel, rte))
799 int parallel_workers;
805 if (parallel_workers <= 0)
911 rel->fdwroutine->GetForeignRelSize(root, rel, rte->
relid);
932 rel->fdwroutine->GetForeignPaths(root, rel, rte->
relid);
950 int parentRTindex = rti;
951 bool has_live_children;
954 double *parent_attrsizes;
970 rte->
relkind == RELKIND_PARTITIONED_TABLE &&
988 has_live_children =
false;
992 parent_attrsizes = (
double *)
palloc0(nattrs *
sizeof(
double));
1010 childRTE = root->simple_rte_array[childRTindex];
1056 childrinfos =
lappend(childrinfos,
1136 has_live_children =
true;
1155 parent_rows += childrel->
rows;
1172 if (
IsA(parentvar,
Var) && parentvar->
varno == parentRTindex)
1175 int32 child_width = 0;
1177 if (
IsA(childvar,
Var) &&
1178 ((
Var *) childvar)->varno == childrel->
relid)
1180 int cndx = ((
Var *) childvar)->varattno - childrel->
min_attr;
1182 child_width = childrel->attr_widths[cndx];
1184 if (child_width <= 0)
1188 parent_attrsizes[pndx] += child_width * childrel->
rows;
1193 if (has_live_children)
1201 rel->
rows = parent_rows;
1203 for (
i = 0;
i < nattrs;
i++)
1204 rel->attr_widths[
i] = rint(parent_attrsizes[
i] / parent_rows);
1210 rel->
tuples = parent_rows;
1227 pfree(parent_attrsizes);
1238 int parentRTindex = rti;
1259 childRTE = root->simple_rte_array[childRTindex];
1260 childrel = root->simple_rel_array[childRTindex];
1285 live_childrels =
lappend(live_childrels, childrel);
1306 List *live_childrels)
1309 bool subpaths_valid =
true;
1311 bool startup_subpaths_valid =
true;
1313 List *pa_partial_subpaths =
NIL;
1314 List *pa_nonpartial_subpaths =
NIL;
1315 bool partial_subpaths_valid =
true;
1316 bool pa_subpaths_valid;
1317 List *all_child_pathkeys =
NIL;
1320 double partial_rows = -1;
1330 foreach(l, live_childrels)
1334 Path *cheapest_partial_path = NULL;
1349 subpaths_valid =
false;
1365 startup_subpaths_valid =
false;
1373 &partial_subpaths, NULL);
1376 partial_subpaths_valid =
false;
1382 if (pa_subpaths_valid)
1384 Path *nppath = NULL;
1389 if (cheapest_partial_path == NULL && nppath == NULL)
1392 pa_subpaths_valid =
false;
1394 else if (nppath == NULL ||
1395 (cheapest_partial_path != NULL &&
1399 Assert(cheapest_partial_path != NULL);
1401 &pa_partial_subpaths,
1402 &pa_nonpartial_subpaths);
1420 &pa_nonpartial_subpaths,
1438 if (childkeys !=
NIL)
1444 foreach(lpk, all_child_pathkeys)
1458 all_child_pathkeys =
lappend(all_child_pathkeys,
1470 foreach(lco, all_child_outers)
1474 if (
bms_equal(existing_outers, childouter))
1483 all_child_outers =
lappend(all_child_outers,
1497 NIL, NULL, 0,
false,
1501 if (startup_subpaths_valid)
1503 NIL,
NIL, NULL, 0,
false, -1));
1509 if (partial_subpaths_valid && partial_subpaths !=
NIL)
1513 int parallel_workers = 0;
1516 foreach(lc, partial_subpaths)
1522 Assert(parallel_workers > 0);
1535 parallel_workers =
Max(parallel_workers,
1537 parallel_workers =
Min(parallel_workers,
1540 Assert(parallel_workers > 0);
1544 NIL, NULL, parallel_workers,
1552 partial_rows = appendpath->
path.
rows;
1564 if (pa_subpaths_valid && pa_nonpartial_subpaths !=
NIL)
1568 int parallel_workers = 0;
1574 foreach(lc, pa_partial_subpaths)
1586 parallel_workers =
Max(parallel_workers,
1588 parallel_workers =
Min(parallel_workers,
1590 Assert(parallel_workers > 0);
1593 pa_partial_subpaths,
1594 NIL, NULL, parallel_workers,
true,
1605 all_child_pathkeys);
1620 foreach(l, all_child_outers)
1627 subpaths_valid =
true;
1628 foreach(lcr, live_childrels)
1636 subpaths_valid =
false;
1646 subpaths_valid =
false;
1655 NIL, required_outer, 0,
false,
1718 List *live_childrels,
1719 List *all_child_pathkeys)
1722 List *partition_pathkeys =
NIL;
1723 List *partition_pathkeys_desc =
NIL;
1724 bool partition_pathkeys_partial =
true;
1725 bool partition_pathkeys_desc_partial =
true;
1740 &partition_pathkeys_partial);
1744 &partition_pathkeys_desc_partial);
1758 foreach(lcp, all_child_pathkeys)
1763 List *fractional_subpaths =
NIL;
1764 bool startup_neq_total =
false;
1765 bool match_partition_order;
1766 bool match_partition_order_desc;
1780 match_partition_order =
1782 (!partition_pathkeys_partial &&
1785 match_partition_order_desc = !match_partition_order &&
1787 (!partition_pathkeys_desc_partial &&
1797 if (match_partition_order_desc)
1808 match_partition_order =
true;
1819 for (
int i = first_index;
i != end_index;
i += direction)
1822 Path *cheapest_startup,
1824 *cheapest_fractional = NULL;
1844 if (cheapest_startup == NULL || cheapest_total == NULL)
1846 cheapest_startup = cheapest_total =
1849 Assert(cheapest_total->param_info == NULL);
1866 cheapest_fractional =
1880 if (!cheapest_fractional)
1881 cheapest_fractional = cheapest_total;
1889 if (cheapest_startup != cheapest_total)
1890 startup_neq_total =
true;
1896 if (match_partition_order)
1908 startup_subpaths =
lappend(startup_subpaths, cheapest_startup);
1909 total_subpaths =
lappend(total_subpaths, cheapest_total);
1911 if (cheapest_fractional)
1914 fractional_subpaths =
lappend(fractional_subpaths, cheapest_fractional);
1924 &startup_subpaths, NULL);
1926 &total_subpaths, NULL);
1928 if (cheapest_fractional)
1930 &fractional_subpaths, NULL);
1935 if (match_partition_order)
1947 if (startup_neq_total)
1958 if (fractional_subpaths)
1961 fractional_subpaths,
1977 if (startup_neq_total)
1984 if (fractional_subpaths)
1987 fractional_subpaths,
2018 Assert(cheapest != NULL);
2043 if (cheapest != NULL &&
2055 if (cheapest != NULL &&
2101 else if (special_subpaths != NULL)
2103 List *new_special_subpaths;
2111 *special_subpaths =
list_concat(*special_subpaths,
2112 new_special_subpaths);
2124 *subpaths =
lappend(*subpaths, path);
2219 bool wfunc_left,
bool *keep_original,
2232 *keep_original =
true;
2268 req.
type = T_SupportRequestWFuncMonotonic;
2288 foreach(lc, opinfos)
2305 *keep_original =
false;
2307 runoperator = opexpr->
opno;
2323 *keep_original =
false;
2325 runoperator = opexpr->
opno;
2342 *keep_original =
false;
2344 runoperator = opexpr->
opno;
2361 *keep_original =
true;
2373 if (runopexpr != NULL)
2383 runopexpr->opresulttype,
2384 runopexpr->opretset, (
Expr *) wfunc,
2385 otherexpr, runopexpr->opcollid,
2386 runopexpr->inputcollid);
2389 runopexpr->opresulttype,
2390 runopexpr->opretset,
2391 otherexpr, (
Expr *) wfunc,
2392 runopexpr->opcollid,
2393 runopexpr->inputcollid);
2395 wclause->runCondition =
lappend(wclause->runCondition, newexpr);
2426 bool keep_original =
true;
2463 opexpr,
true, &keep_original,
2465 return keep_original;
2476 opexpr,
false, &keep_original,
2478 return keep_original;
2502 bool trivial_pathtarget;
2505 double tuple_fraction;
2532 memset(&safetyInfo, 0,
sizeof(safetyInfo));
2569 List *upperrestrictlist =
NIL;
2577 if (rinfo->pseudoconstant)
2579 upperrestrictlist =
lappend(upperrestrictlist, rinfo);
2598 if (!subquery->hasWindowFuncs ||
2607 upperrestrictlist =
lappend(upperrestrictlist, rinfo);
2612 upperrestrictlist =
lappend(upperrestrictlist, rinfo);
2636 if (
parse->hasAggs ||
2637 parse->groupClause ||
2638 parse->groupingSets ||
2640 parse->distinctClause ||
2641 parse->sortClause ||
2643 tuple_fraction = 0.0;
2653 false, tuple_fraction);
2685 trivial_pathtarget =
false;
2688 trivial_pathtarget =
true;
2696 trivial_pathtarget =
false;
2700 if (var->
varno != rti ||
2703 trivial_pathtarget =
false;
2713 foreach(lc, sub_final_rel->
pathlist)
2728 pathkeys, required_outer));
2824 pathkeys, required_outer));
2891 while (levelsup-- > 0)
2893 cteroot = cteroot->parent_root;
3020 while (levelsup-- > 0)
3022 cteroot = cteroot->parent_root;
3064 Path *cheapest_partial_path;
3065 Path *simple_gather_path;
3068 double *rowsp = NULL;
3086 simple_gather_path = (
Path *)
3105 subpath->pathkeys, NULL, rowsp);
3133 bool require_parallel_safe)
3135 List *useful_pathkeys_list =
NIL;
3166 require_parallel_safe))
3178 useful_pathkeys_list =
lappend(useful_pathkeys_list,
3180 else if (npathkeys > 0)
3181 useful_pathkeys_list =
lappend(useful_pathkeys_list,
3186 return useful_pathkeys_list;
3204 double *rowsp = NULL;
3205 List *useful_pathkeys_list =
NIL;
3206 Path *cheapest_partial_path = NULL;
3229 foreach(lc, useful_pathkeys_list)
3264 if (
subpath != cheapest_partial_path &&
3329 if (levels_needed <= 0)
3338 foreach(jl, joinlist)
3356 elog(
ERROR,
"unrecognized joinlist node type: %d",
3361 initial_rels =
lappend(initial_rels, thisrel);
3364 if (levels_needed == 1)
3380 root->initial_rels = initial_rels;
3385 return geqo(root, levels_needed, initial_rels);
3430 Assert(root->join_rel_level == NULL);
3443 root->join_rel_level = (
List **)
palloc0((levels_needed + 1) *
sizeof(
List *));
3445 root->join_rel_level[1] = initial_rels;
3447 for (lev = 2; lev <= levels_needed; lev++)
3468 foreach(lc, root->join_rel_level[lev])
3487 #ifdef OPTIMIZER_DEBUG
3496 if (root->join_rel_level[levels_needed] ==
NIL)
3497 elog(
ERROR,
"failed to build any %d-way joins", levels_needed);
3502 root->join_rel_level = NULL;
3607 subquery->hasWindowFuncs ||
3608 subquery->hasTargetSRFs)
3621 if (subquery == topquery)
3657 Assert(subquery != NULL);
3675 elog(
ERROR,
"unrecognized node type: %d",
3729 if (subquery->hasTargetSRFs &&
3748 if (subquery->hasDistinctOn &&
3759 if (subquery->hasWindowFuncs &&
3801 if (colType == NULL)
3802 elog(
ERROR,
"wrong number of tlist entries");
3805 colType =
lnext(colTypes, colType);
3807 if (colType != NULL)
3808 elog(
ERROR,
"wrong number of tlist entries");
3922 if (var->
varno != rti)
3988 &subquery->hasSubLinks);
4022 Assert(subquery != NULL);
4034 elog(
ERROR,
"unrecognized node type: %d",
4075 attrs_used = extra_used_attrs;
4150 if (subquery->hasTargetSRFs &&
4180 int parallel_workers;
4181 double pages_fetched;
4190 if (parallel_workers <= 0)
4216 int parallel_workers = 0;
4239 if (heap_pages >= 0)
4241 int heap_parallel_threshold;
4242 int heap_parallel_workers = 1;
4252 while (heap_pages >= (
BlockNumber) (heap_parallel_threshold * 3))
4254 heap_parallel_workers++;
4255 heap_parallel_threshold *= 3;
4256 if (heap_parallel_threshold > INT_MAX / 3)
4260 parallel_workers = heap_parallel_workers;
4263 if (index_pages >= 0)
4265 int index_parallel_workers = 1;
4266 int index_parallel_threshold;
4270 while (index_pages >= (
BlockNumber) (index_parallel_threshold * 3))
4272 index_parallel_workers++;
4273 index_parallel_threshold *= 3;
4274 if (index_parallel_threshold > INT_MAX / 3)
4278 if (parallel_workers > 0)
4279 parallel_workers =
Min(parallel_workers, index_parallel_workers);
4281 parallel_workers = index_parallel_workers;
4286 parallel_workers =
Min(parallel_workers, max_workers);
4288 return parallel_workers;
4323 part_rels = rel->part_rels;
4326 for (cnt_parts = 0; cnt_parts < num_parts; cnt_parts++)
4328 RelOptInfo *child_rel = part_rels[cnt_parts];
4331 if (child_rel == NULL)
4355 #ifdef OPTIMIZER_DEBUG
4359 live_children =
lappend(live_children, child_rel);
static void set_base_rel_sizes(PlannerInfo *root)
static void set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
static bool find_window_run_conditions(Query *subquery, RangeTblEntry *rte, Index rti, AttrNumber attno, WindowFunc *wfunc, OpExpr *opexpr, bool wfunc_left, bool *keep_original, Bitmapset **run_cond_attrs)
#define UNSAFE_TYPE_MISMATCH
static Path * get_cheapest_parameterized_child_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
static void set_namedtuplestore_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void subquery_push_qual(Query *subquery, RangeTblEntry *rte, Index rti, Node *qual)
void generate_partitionwise_join_paths(PlannerInfo *root, RelOptInfo *rel)
RelOptInfo * standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
static void set_base_rel_consider_startup(PlannerInfo *root)
#define UNSAFE_HAS_VOLATILE_FUNC
#define UNSAFE_NOTIN_DISTINCTON_CLAUSE
static void set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
static Path * get_singleton_append_subpath(Path *path)
static void set_tablesample_rel_size(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void set_tablesample_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void set_foreign_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void set_base_rel_pathlists(PlannerInfo *root)
static void set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
static pushdown_safe_type qual_is_pushdown_safe(Query *subquery, Index rti, RestrictInfo *rinfo, pushdown_safety_info *safetyInfo)
static void set_result_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
int compute_parallel_worker(RelOptInfo *rel, double heap_pages, double index_pages, int max_workers)
void generate_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_rows)
static void set_dummy_rel_pathlist(RelOptInfo *rel)
static void compare_tlist_datatypes(List *tlist, List *colTypes, pushdown_safety_info *safetyInfo)
static void set_worktable_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static bool targetIsInAllPartitionLists(TargetEntry *tle, Query *query)
static void create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
static bool subquery_is_pushdown_safe(Query *subquery, Query *topquery, pushdown_safety_info *safetyInfo)
join_search_hook_type join_search_hook
static bool check_and_push_window_quals(Query *subquery, RangeTblEntry *rte, Index rti, Node *clause, Bitmapset **run_cond_attrs)
void generate_useful_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_rows)
static RelOptInfo * make_rel_from_joinlist(PlannerInfo *root, List *joinlist)
static void set_function_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void recurse_push_qual(Node *setOp, Query *topquery, RangeTblEntry *rte, Index rti, Node *qual)
static void set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static List * get_useful_pathkeys_for_relation(PlannerInfo *root, RelOptInfo *rel, bool require_parallel_safe)
static void remove_unused_subquery_outputs(Query *subquery, RelOptInfo *rel, Bitmapset *extra_used_attrs)
static void check_output_expressions(Query *subquery, pushdown_safety_info *safetyInfo)
static void set_tablefunc_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void set_foreign_size(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
set_rel_pathlist_hook_type set_rel_pathlist_hook
static void set_values_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
struct pushdown_safety_info pushdown_safety_info
#define UNSAFE_HAS_SET_FUNC
static void set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
void create_partial_bitmap_paths(PlannerInfo *root, RelOptInfo *rel, Path *bitmapqual)
static void set_plain_rel_size(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
void add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, List *live_childrels)
static void set_rel_size(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
static void generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel, List *live_childrels, List *all_child_pathkeys)
#define UNSAFE_NOTIN_PARTITIONBY_CLAUSE
RelOptInfo * make_one_rel(PlannerInfo *root, List *joinlist)
static bool recurse_pushdown_safe(Node *setOp, Query *topquery, pushdown_safety_info *safetyInfo)
@ PUSHDOWN_WINDOWCLAUSE_RUNCOND
static void accumulate_append_subpath(Path *path, List **subpaths, List **special_subpaths)
int min_parallel_index_scan_size
int min_parallel_table_scan_size
Node * adjust_appendrel_attrs(PlannerInfo *root, Node *node, int nappinfos, AppendRelInfo **appinfos)
#define InvalidAttrNumber
void pprint(const void *obj)
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
BMS_Membership bms_membership(const Bitmapset *a)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
bool bms_get_singleton_member(const Bitmapset *a, int *member)
#define OidIsValid(objectId)
bool is_pseudo_constant_clause(Node *clause)
bool contain_leaked_vars(Node *clause)
bool is_parallel_safe(PlannerInfo *root, Node *node)
bool contain_subplans(Node *clause)
bool contain_volatile_functions(Node *clause)
void set_namedtuplestore_size_estimates(PlannerInfo *root, RelOptInfo *rel)
int max_parallel_workers_per_gather
void set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel)
double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel, Path *bitmapqual, int loop_count, Cost *cost, double *tuple)
void set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel, double cte_rows)
void set_result_size_estimates(PlannerInfo *root, RelOptInfo *rel)
bool enable_partitionwise_join
void set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel)
bool enable_parallel_append
void set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
double clamp_row_est(double nrows)
void set_tablefunc_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel)
bool enable_incremental_sort
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
void add_child_rel_equivalences(PlannerInfo *root, AppendRelInfo *appinfo, RelOptInfo *parent_rel, RelOptInfo *child_rel)
bool relation_can_be_sorted_early(PlannerInfo *root, RelOptInfo *rel, EquivalenceClass *ec, bool require_parallel_safe)
#define OidFunctionCall1(functionId, arg1)
RelOptInfo * geqo(PlannerInfo *root, int number_of_rels, List *initial_rels)
void check_index_predicates(PlannerInfo *root, RelOptInfo *rel)
void create_index_paths(PlannerInfo *root, RelOptInfo *rel)
if(TABLE==NULL||TABLE_index==NULL)
void join_search_one_level(PlannerInfo *root, int level)
void mark_dummy_rel(RelOptInfo *rel)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
List * list_copy_head(const List *oldlist, int len)
void list_free(List *list)
List * list_copy_tail(const List *oldlist, int nskip)
List * list_concat(List *list1, const List *list2)
char get_rel_persistence(Oid relid)
char func_parallel(Oid funcid)
RegProcedure get_func_support(Oid funcid)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
bool func_strict(Oid funcid)
List * get_op_btree_interpretation(Oid opno)
int32 get_typavgwidth(Oid typid, int32 typmod)
Datum subpath(PG_FUNCTION_ARGS)
Expr * make_opclause(Oid opno, Oid opresulttype, bool opretset, Expr *leftop, Expr *rightop, Oid opcollid, Oid inputcollid)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Node * make_and_qual(Node *qual1, Node *qual2)
void pfree(void *pointer)
void * palloc0(Size size)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
bool expression_returns_set(Node *clause)
void set_opfuncid(OpExpr *opexpr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
#define PVC_INCLUDE_PLACEHOLDERS
bool targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList)
#define rt_fetch(rangetable_index, rangetable)
bool partitions_are_ordered(PartitionBoundInfo boundinfo, Bitmapset *live_parts)
List * build_expression_pathkey(PlannerInfo *root, Expr *expr, Oid opno, Relids rel, bool create_it)
Path * get_cheapest_path_for_pathkeys(List *paths, List *pathkeys, Relids required_outer, CostSelector cost_criterion, bool require_parallel_safe)
bool pathkeys_count_contained_in(List *keys1, List *keys2, int *n_common)
bool has_useful_pathkeys(PlannerInfo *root, RelOptInfo *rel)
Path * get_cheapest_parallel_safe_total_inner(List *paths)
List * convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel, List *subquery_pathkeys, List *subquery_tlist)
Path * get_cheapest_fractional_path_for_pathkeys(List *paths, List *pathkeys, Relids required_outer, double fraction)
bool pathkeys_contained_in(List *keys1, List *keys2)
PathKeysComparison compare_pathkeys(List *keys1, List *keys2)
List * build_partition_pathkeys(PlannerInfo *root, RelOptInfo *partrel, ScanDirection scandir, bool *partialkeys)
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)
SortPath * create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, double limit_tuples)
GatherMergePath * create_gather_merge_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *pathkeys, Relids required_outer, double *rows)
Path * create_tablefuncscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Path * create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
GatherPath * create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, Relids required_outer, double *rows)
Path * create_resultscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Path * create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
MergeAppendPath * create_merge_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *pathkeys, Relids required_outer)
void set_cheapest(RelOptInfo *parent_rel)
Path * reparameterize_path(PlannerInfo *root, Path *path, Relids required_outer, double loop_count)
SubqueryScanPath * create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, bool trivial_pathtarget, List *pathkeys, Relids required_outer)
Path * create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
void add_partial_path(RelOptInfo *parent_rel, Path *new_path)
MaterialPath * create_material_path(RelOptInfo *rel, Path *subpath)
Path * create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
IncrementalSortPath * create_incremental_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, int presorted_keys, double limit_tuples)
Path * create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
void add_path(RelOptInfo *parent_rel, Path *new_path)
Path * create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
int compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
Path * create_seqscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer, int parallel_workers)
BitmapHeapPath * create_bitmap_heap_path(PlannerInfo *root, RelOptInfo *rel, Path *bitmapqual, Relids required_outer, double loop_count, int parallel_degree)
#define IS_SIMPLE_REL(rel)
#define IS_PARTITIONED_REL(rel)
#define PATH_REQ_OUTER(path)
@ RELOPT_OTHER_MEMBER_REL
RelOptInfo *(* join_search_hook_type)(PlannerInfo *root, int levels_needed, List *initial_rels)
void(* set_rel_pathlist_hook_type)(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
static int pg_leftmost_one_pos32(uint32 word)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
static ListCell * list_head(const List *l)
#define for_each_from(cell, lst, N)
static void * list_nth(const List *list, int n)
#define list_nth_node(type, list, n)
static ListCell * lnext(const List *l, const ListCell *c)
static int list_nth_int(const List *list, int n)
#define foreach_current_index(cell)
bool relation_excluded_by_constraints(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
PlannerInfo * subquery_planner(PlannerGlobal *glob, Query *parse, PlannerInfo *parent_root, bool hasRecursion, double tuple_fraction)
bool limit_needed(Query *parse)
@ MONOTONICFUNC_DECREASING
@ MONOTONICFUNC_INCREASING
void check_stack_depth(void)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
Node * ReplaceVarsFromTargetList(Node *node, int target_varno, int sublevels_up, RangeTblEntry *target_rte, List *targetlist, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno, bool *outer_hasSubLinks)
@ REPLACEVARS_REPORT_ERROR
#define BTGreaterStrategyNumber
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
#define BTLessEqualStrategyNumber
#define BTGreaterEqualStrategyNumber
int simple_rel_array_size
struct Path * non_recursive_path
Cardinality total_table_pages
Selectivity tuple_fraction
struct TableSampleClause * tablesample
bool consider_param_startup
struct PathTarget * reltarget
struct Path * cheapest_startup_path
struct Path * cheapest_total_path
bool consider_partitionwise_join
struct WindowClause * window_clause
bool repeatable_across_scans
SampleScanGetSampleSize_function SampleScanGetSampleSize
unsigned char * unsafeFlags
#define FirstLowInvalidHeapAttributeNumber
TsmRoutine * GetTsmRoutine(Oid tsmhandler)
void create_tidscan_paths(PlannerInfo *root, RelOptInfo *rel)
List * make_tlist_from_pathtarget(PathTarget *target)
List * pull_var_clause(Node *node, int flags)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)