55#define UNSAFE_HAS_VOLATILE_FUNC (1 << 0)
56#define UNSAFE_HAS_SET_FUNC (1 << 1)
57#define UNSAFE_NOTIN_DISTINCTON_CLAUSE (1 << 2)
58#define UNSAFE_NOTIN_PARTITIONBY_CLAUSE (1 << 3)
59#define UNSAFE_TYPE_MISMATCH (1 << 4)
124 List *live_childrels,
125 List *all_child_pathkeys);
131 List **special_subpaths);
212 for (rti = 1; rti <
root->simple_rel_array_size; rti++)
226 total_pages += (double) brel->
pages;
228 root->total_table_pages = total_pages;
276 foreach(lc,
root->join_info_list)
306 for (rti = 1; rti <
root->simple_rel_array_size; rti++)
321 rte =
root->simple_rte_array[rti];
331 if (
root->glob->parallelModeOK)
352 if (
root->agg_clause_list ==
NIL ||
356 for (rti = 1; rti <
root->simple_rel_array_size; rti++)
382 for (rti = 1; rti <
root->simple_rel_array_size; rti++)
434 if (rte->relkind == RELKIND_FOREIGN_TABLE)
439 else if (rte->relkind == RELKIND_PARTITIONED_TABLE)
484 if (rte->self_reference)
531 if (rte->relkind == RELKIND_FOREIGN_TABLE)
584 (*set_rel_pathlist_hook) (
root, rel, rti, rte);
616#ifdef OPTIMIZER_DEBUG
684 if (proparallel != PROPARALLEL_SAFE)
698 if (rte->relkind == RELKIND_FOREIGN_TABLE)
701 if (!rel->fdwroutine->IsForeignScanParallelSafe)
703 if (!rel->fdwroutine->IsForeignScanParallelSafe(
root, rel, rte))
862 int parallel_workers;
868 if (parallel_workers <= 0)
951 if ((
root->query_level > 1 ||
974 rel->fdwroutine->GetForeignRelSize(
root, rel, rte->relid);
995 rel->fdwroutine->GetForeignPaths(
root, rel, rte->relid);
1013 int parentRTindex = rti;
1014 bool has_live_children;
1015 double parent_tuples;
1018 double *parent_attrsizes;
1034 rte->relkind == RELKIND_PARTITIONED_TABLE &&
1061 has_live_children =
false;
1066 parent_attrsizes = (
double *)
palloc0(nattrs *
sizeof(
double));
1068 foreach(l,
root->append_rel_list)
1084 childRTE =
root->simple_rte_array[childRTindex];
1130 childrinfos =
lappend(childrinfos,
1210 has_live_children =
true;
1229 parent_tuples += childrel->
tuples;
1230 parent_rows += childrel->
rows;
1247 if (
IsA(parentvar,
Var) && parentvar->
varno == parentRTindex)
1250 int32 child_width = 0;
1252 if (
IsA(childvar,
Var) &&
1253 ((
Var *) childvar)->varno == childrel->
relid)
1255 int cndx = ((
Var *) childvar)->varattno - childrel->
min_attr;
1257 child_width = childrel->attr_widths[cndx];
1259 if (child_width <= 0)
1263 parent_attrsizes[pndx] += child_width * childrel->
rows;
1268 if (has_live_children)
1276 rel->
tuples = parent_tuples;
1277 rel->
rows = parent_rows;
1279 for (
i = 0;
i < nattrs;
i++)
1280 rel->attr_widths[
i] = rint(parent_attrsizes[
i] / parent_rows);
1297 pfree(parent_attrsizes);
1308 int parentRTindex = rti;
1316 foreach(l,
root->append_rel_list)
1329 childRTE =
root->simple_rte_array[childRTindex];
1330 childrel =
root->simple_rel_array[childRTindex];
1355 live_childrels =
lappend(live_childrels, childrel);
1376 if (
root->agg_clause_list ==
NIL ||
1405 List *live_childrels)
1408 bool subpaths_valid =
true;
1410 bool startup_subpaths_valid =
true;
1412 List *pa_partial_subpaths =
NIL;
1413 List *pa_nonpartial_subpaths =
NIL;
1414 bool partial_subpaths_valid =
true;
1415 bool pa_subpaths_valid;
1416 List *all_child_pathkeys =
NIL;
1419 double partial_rows = -1;
1429 foreach(l, live_childrels)
1433 Path *cheapest_partial_path = NULL;
1448 subpaths_valid =
false;
1457 Path *cheapest_path;
1464 if (
root->tuple_fraction > 0.0)
1467 root->tuple_fraction);
1472 Assert(cheapest_path->param_info == NULL);
1478 startup_subpaths_valid =
false;
1486 &partial_subpaths, NULL);
1489 partial_subpaths_valid =
false;
1495 if (pa_subpaths_valid)
1497 Path *nppath = NULL;
1502 if (cheapest_partial_path == NULL && nppath == NULL)
1505 pa_subpaths_valid =
false;
1507 else if (nppath == NULL ||
1508 (cheapest_partial_path != NULL &&
1512 Assert(cheapest_partial_path != NULL);
1514 &pa_partial_subpaths,
1515 &pa_nonpartial_subpaths);
1533 &pa_nonpartial_subpaths,
1551 if (childkeys !=
NIL)
1557 foreach(lpk, all_child_pathkeys)
1571 all_child_pathkeys =
lappend(all_child_pathkeys,
1583 foreach(lco, all_child_outers)
1587 if (
bms_equal(existing_outers, childouter))
1596 all_child_outers =
lappend(all_child_outers,
1610 NIL, NULL, 0,
false,
1614 if (startup_subpaths_valid)
1616 NIL,
NIL, NULL, 0,
false, -1));
1622 if (partial_subpaths_valid && partial_subpaths !=
NIL)
1626 int parallel_workers = 0;
1629 foreach(lc, partial_subpaths)
1635 Assert(parallel_workers > 0);
1648 parallel_workers =
Max(parallel_workers,
1650 parallel_workers =
Min(parallel_workers,
1653 Assert(parallel_workers > 0);
1657 NIL, NULL, parallel_workers,
1665 partial_rows = appendpath->
path.
rows;
1677 if (pa_subpaths_valid && pa_nonpartial_subpaths !=
NIL)
1681 int parallel_workers = 0;
1687 foreach(lc, pa_partial_subpaths)
1699 parallel_workers =
Max(parallel_workers,
1701 parallel_workers =
Min(parallel_workers,
1703 Assert(parallel_workers > 0);
1706 pa_partial_subpaths,
1707 NIL, NULL, parallel_workers,
true,
1718 all_child_pathkeys);
1733 foreach(l, all_child_outers)
1740 subpaths_valid =
true;
1741 foreach(lcr, live_childrels)
1749 subpaths_valid =
false;
1759 subpaths_valid =
false;
1768 NIL, required_outer, 0,
false,
1833 List *live_childrels,
1834 List *all_child_pathkeys)
1837 List *partition_pathkeys =
NIL;
1838 List *partition_pathkeys_desc =
NIL;
1839 bool partition_pathkeys_partial =
true;
1840 bool partition_pathkeys_desc_partial =
true;
1855 &partition_pathkeys_partial);
1859 &partition_pathkeys_desc_partial);
1873 foreach(lcp, all_child_pathkeys)
1878 List *fractional_subpaths =
NIL;
1879 bool startup_neq_total =
false;
1880 bool fraction_neq_total =
false;
1881 bool match_partition_order;
1882 bool match_partition_order_desc;
1896 match_partition_order =
1898 (!partition_pathkeys_partial &&
1901 match_partition_order_desc = !match_partition_order &&
1903 (!partition_pathkeys_desc_partial &&
1913 if (match_partition_order_desc)
1924 match_partition_order =
true;
1935 for (
int i = first_index;
i != end_index;
i += direction)
1938 Path *cheapest_startup,
1940 *cheapest_fractional = NULL;
1960 if (cheapest_startup == NULL || cheapest_total == NULL)
1962 cheapest_startup = cheapest_total =
1965 Assert(cheapest_total->param_info == NULL);
1978 if (
root->tuple_fraction > 0)
1980 double path_fraction =
root->tuple_fraction;
1993 if (path_fraction >= 1.0)
1994 path_fraction /= cheapest_total->
rows;
1996 cheapest_fractional =
2014 if (cheapest_fractional == NULL)
2015 cheapest_fractional = cheapest_total;
2016 else if (cheapest_fractional != cheapest_total)
2017 fraction_neq_total =
true;
2025 if (cheapest_startup != cheapest_total)
2026 startup_neq_total =
true;
2032 if (match_partition_order)
2044 startup_subpaths =
lappend(startup_subpaths, cheapest_startup);
2045 total_subpaths =
lappend(total_subpaths, cheapest_total);
2047 if (cheapest_fractional)
2050 fractional_subpaths =
lappend(fractional_subpaths, cheapest_fractional);
2060 &startup_subpaths, NULL);
2062 &total_subpaths, NULL);
2064 if (cheapest_fractional)
2066 &fractional_subpaths, NULL);
2071 if (match_partition_order)
2083 if (startup_neq_total)
2094 if (fractional_subpaths && fraction_neq_total)
2097 fractional_subpaths,
2113 if (startup_neq_total)
2120 if (fractional_subpaths && fraction_neq_total)
2123 fractional_subpaths,
2154 Assert(cheapest != NULL);
2179 if (cheapest != NULL &&
2191 if (cheapest != NULL &&
2237 else if (special_subpaths != NULL)
2239 List *new_special_subpaths;
2247 *special_subpaths =
list_concat(*special_subpaths,
2248 new_special_subpaths);
2260 *subpaths =
lappend(*subpaths, path);
2355 bool *keep_original,
Bitmapset **run_cond_attrs)
2367 *keep_original =
true;
2403 req.
type = T_SupportRequestWFuncMonotonic;
2423 foreach(lc, opinfos)
2439 *keep_original =
false;
2441 runoperator = opexpr->
opno;
2456 *keep_original =
false;
2458 runoperator = opexpr->
opno;
2475 *keep_original =
false;
2477 runoperator = opexpr->
opno;
2494 *keep_original =
true;
2506 if (runopexpr != NULL)
2511 wfuncrc->
opno = runoperator;
2512 wfuncrc->inputcollid = runopexpr->inputcollid;
2516 wfunc->runCondition =
lappend(wfunc->runCondition, wfuncrc);
2547 bool keep_original =
true;
2584 true, &keep_original, run_cond_attrs))
2585 return keep_original;
2596 false, &keep_original, run_cond_attrs))
2597 return keep_original;
2621 bool trivial_pathtarget;
2624 double tuple_fraction;
2652 memset(&safetyInfo, 0,
sizeof(safetyInfo));
2689 List *upperrestrictlist =
NIL;
2697 if (rinfo->pseudoconstant)
2699 upperrestrictlist =
lappend(upperrestrictlist, rinfo);
2718 if (!subquery->hasWindowFuncs ||
2727 upperrestrictlist =
lappend(upperrestrictlist, rinfo);
2732 upperrestrictlist =
lappend(upperrestrictlist, rinfo);
2756 if (
parse->hasAggs ||
2757 parse->groupClause ||
2758 parse->groupingSets ||
2759 root->hasHavingQual ||
2760 parse->distinctClause ||
2761 parse->sortClause ||
2763 tuple_fraction = 0.0;
2765 tuple_fraction =
root->tuple_fraction;
2773 root,
false, tuple_fraction, NULL);
2805 trivial_pathtarget =
false;
2808 trivial_pathtarget =
true;
2816 trivial_pathtarget =
false;
2820 if (var->
varno != rti ||
2823 trivial_pathtarget =
false;
2833 foreach(lc, sub_final_rel->
pathlist)
2848 pathkeys, required_outer));
2944 pathkeys, required_outer));
3014 while (levelsup-- > 0)
3016 cteroot = cteroot->parent_root;
3146 while (levelsup-- > 0)
3148 cteroot = cteroot->parent_root;
3190 Path *cheapest_partial_path;
3191 Path *simple_gather_path;
3194 double *rowsp = NULL;
3211 simple_gather_path = (
Path *)
3230 subpath->pathkeys, NULL, rowsp);
3258 bool require_parallel_safe)
3260 List *useful_pathkeys_list =
NIL;
3268 if (
root->query_pathkeys)
3273 foreach(lc,
root->query_pathkeys)
3291 require_parallel_safe))
3303 useful_pathkeys_list =
lappend(useful_pathkeys_list,
3304 root->query_pathkeys);
3305 else if (npathkeys > 0)
3306 useful_pathkeys_list =
lappend(useful_pathkeys_list,
3311 return useful_pathkeys_list;
3329 double *rowsp = NULL;
3330 List *useful_pathkeys_list =
NIL;
3331 Path *cheapest_partial_path = NULL;
3354 foreach(lc, useful_pathkeys_list)
3389 if (
subpath != cheapest_partial_path &&
3449 Path *cheapest_total_path = NULL;
3450 Path *cheapest_partial_path = NULL;
3451 double dNumGroups = 0;
3452 double dNumPartialGroups = 0;
3481 List *top_group_tlist;
3508 Assert(cheapest_total_path != NULL);
3519 Assert(cheapest_partial_path != NULL);
3523 if (cheapest_total_path != NULL)
3526 cheapest_total_path->
rows,
3528 if (cheapest_partial_path != NULL)
3531 cheapest_partial_path->
rows,
3534 if (can_sort && cheapest_total_path != NULL)
3557 if (input_path->param_info &&
3558 input_path != cheapest_total_path)
3570 if (!is_sorted && input_path != cheapest_total_path &&
3625 if (can_sort && cheapest_partial_path != NULL)
3646 if (!is_sorted && input_path != cheapest_partial_path &&
3704 if (can_hash && cheapest_total_path != NULL)
3715 cheapest_total_path,
3739 if (can_hash && cheapest_partial_path != NULL)
3750 cheapest_partial_path,
3793 if (levels_needed <= 0)
3802 foreach(jl, joinlist)
3820 elog(
ERROR,
"unrecognized joinlist node type: %d",
3825 initial_rels =
lappend(initial_rels, thisrel);
3828 if (levels_needed == 1)
3844 root->initial_rels = initial_rels;
3849 return geqo(
root, levels_needed, initial_rels);
3909 root->join_rel_level[1] = initial_rels;
3911 for (lev = 2; lev <= levels_needed; lev++)
3936 foreach(lc,
root->join_rel_level[lev])
3975#ifdef OPTIMIZER_DEBUG
3984 if (
root->join_rel_level[levels_needed] ==
NIL)
3985 elog(
ERROR,
"failed to build any %d-way joins", levels_needed);
3990 root->join_rel_level = NULL;
4095 subquery->hasWindowFuncs ||
4096 subquery->hasTargetSRFs)
4109 if (subquery == topquery)
4145 Assert(subquery != NULL);
4163 elog(
ERROR,
"unrecognized node type: %d",
4217 if (subquery->hasTargetSRFs &&
4236 if (subquery->hasDistinctOn &&
4247 if (subquery->hasWindowFuncs &&
4289 if (colType == NULL)
4290 elog(
ERROR,
"wrong number of tlist entries");
4293 colType =
lnext(colTypes, colType);
4295 if (colType != NULL)
4296 elog(
ERROR,
"wrong number of tlist entries");
4410 if (var->
varno != rti)
4475 subquery->resultRelation,
4477 &subquery->hasSubLinks);
4511 Assert(subquery != NULL);
4523 elog(
ERROR,
"unrecognized node type: %d",
4564 attrs_used = extra_used_attrs;
4639 if (subquery->hasTargetSRFs &&
4669 int parallel_workers;
4670 double pages_fetched;
4679 if (parallel_workers <= 0)
4705 int parallel_workers = 0;
4728 if (heap_pages >= 0)
4730 int heap_parallel_threshold;
4731 int heap_parallel_workers = 1;
4741 while (heap_pages >= (
BlockNumber) (heap_parallel_threshold * 3))
4743 heap_parallel_workers++;
4744 heap_parallel_threshold *= 3;
4745 if (heap_parallel_threshold > INT_MAX / 3)
4749 parallel_workers = heap_parallel_workers;
4752 if (index_pages >= 0)
4754 int index_parallel_workers = 1;
4755 int index_parallel_threshold;
4759 while (index_pages >= (
BlockNumber) (index_parallel_threshold * 3))
4761 index_parallel_workers++;
4762 index_parallel_threshold *= 3;
4763 if (index_parallel_threshold > INT_MAX / 3)
4767 if (parallel_workers > 0)
4768 parallel_workers =
Min(parallel_workers, index_parallel_workers);
4770 parallel_workers = index_parallel_workers;
4775 parallel_workers =
Min(parallel_workers, max_workers);
4777 return parallel_workers;
4812 part_rels = rel->part_rels;
4815 for (cnt_parts = 0; cnt_parts < num_parts; cnt_parts++)
4817 RelOptInfo *child_rel = part_rels[cnt_parts];
4820 if (child_rel == NULL)
4853 root->all_query_rels))
4863#ifdef OPTIMIZER_DEBUG
4867 live_children =
lappend(live_children, child_rel);
static void set_base_rel_sizes(PlannerInfo *root)
static List * get_useful_pathkeys_for_relation(PlannerInfo *root, RelOptInfo *rel, bool require_parallel_safe)
static void set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
#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)
void generate_grouped_paths(PlannerInfo *root, RelOptInfo *grouped_rel, RelOptInfo *rel)
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)
RelOptInfo * standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
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)
static bool check_and_push_window_quals(Query *subquery, Node *clause, Bitmapset **run_cond_attrs)
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
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 void setup_simple_grouped_rels(PlannerInfo *root)
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
RelOptInfo * make_one_rel(PlannerInfo *root, List *joinlist)
#define UNSAFE_HAS_SET_FUNC
static void set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
bool enable_eager_aggregate
static void set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
static void set_grouped_rel_pathlist(PlannerInfo *root, RelOptInfo *rel)
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)
double min_eager_agg_group_size
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
static bool find_window_run_conditions(Query *subquery, AttrNumber attno, WindowFunc *wfunc, OpExpr *opexpr, bool wfunc_left, bool *keep_original, Bitmapset **run_cond_attrs)
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 MemSet(start, val, len)
#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)
void set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel, double cte_rows)
double compute_gather_rows(Path *path)
void set_result_size_estimates(PlannerInfo *root, RelOptInfo *rel)
bool enable_partitionwise_join
double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel, Path *bitmapqual, double loop_count, Cost *cost_p, double *tuples_p)
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
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)
Assert(PointerIsAligned(start, uint64))
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)
List * lappend(List *list, void *datum)
List * list_copy_tail(const List *oldlist, int nskip)
List * list_concat(List *list1, const List *list2)
void list_free(List *list)
List * list_copy_head(const List *oldlist, int len)
char get_rel_persistence(Oid relid)
char func_parallel(Oid funcid)
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
RegProcedure get_func_support(Oid funcid)
bool func_strict(Oid funcid)
List * get_op_index_interpretation(Oid opno)
int32 get_typavgwidth(Oid typid, int32 typmod)
Datum subpath(PG_FUNCTION_ARGS)
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_)
@ AGGSPLIT_INITIAL_SERIAL
#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)
Path * get_cheapest_fractional_path_for_pathkeys(List *paths, List *pathkeys, Relids required_outer, double fraction)
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)
List * make_pathkeys_for_sortclauses(PlannerInfo *root, List *sortclauses, List *tlist)
List * build_expression_pathkey(PlannerInfo *root, Expr *expr, Oid opno, Relids rel, bool create_it)
List * build_partition_pathkeys(PlannerInfo *root, RelOptInfo *partrel, ScanDirection scandir, bool *partialkeys)
List * convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel, List *subquery_pathkeys, List *subquery_tlist)
bool pathkeys_contained_in(List *keys1, List *keys2)
PathKeysComparison compare_pathkeys(List *keys1, List *keys2)
Path * get_cheapest_parallel_safe_total_inner(List *paths)
Path * create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
Path * create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Path * create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
ProjectionPath * create_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
Path * create_seqscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer, int parallel_workers)
GatherMergePath * create_gather_merge_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, List *pathkeys, Relids required_outer, double *rows)
void set_cheapest(RelOptInfo *parent_rel)
void add_partial_path(RelOptInfo *parent_rel, Path *new_path)
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)
Path * create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
SubqueryScanPath * create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, bool trivial_pathtarget, List *pathkeys, Relids required_outer)
IncrementalSortPath * create_incremental_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, int presorted_keys, double limit_tuples)
BitmapHeapPath * create_bitmap_heap_path(PlannerInfo *root, RelOptInfo *rel, Path *bitmapqual, Relids required_outer, double loop_count, int parallel_degree)
Path * create_tablefuncscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
SortPath * create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, double limit_tuples)
GatherPath * create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target, Relids required_outer, double *rows)
Path * create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
MaterialPath * create_material_path(RelOptInfo *rel, Path *subpath)
void add_path(RelOptInfo *parent_rel, Path *new_path)
int compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
Path * create_resultscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
Path * create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, List *pathkeys, Relids required_outer)
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)
MergeAppendPath * create_merge_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *pathkeys, Relids required_outer)
Path * reparameterize_path(PlannerInfo *root, Path *path, Relids required_outer, double loop_count)
#define IS_SIMPLE_REL(rel)
#define IS_PARTITIONED_REL(rel)
#define IS_GROUPED_REL(rel)
#define PATH_REQ_OUTER(path)
@ RELOPT_OTHER_MEMBER_REL
#define IS_OTHER_REL(rel)
void(* set_rel_pathlist_hook_type)(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte)
RelOptInfo *(* join_search_hook_type)(PlannerInfo *root, int levels_needed, List *initial_rels)
static int pg_leftmost_one_pos32(uint32 word)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_current_index(var_or_cell)
#define for_each_from(cell, lst, N)
static void * list_nth(const List *list, int n)
static ListCell * list_head(const List *l)
#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)
bool relation_excluded_by_constraints(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
char * choose_plan_name(PlannerGlobal *glob, const char *name, bool always_number)
PlannerInfo * subquery_planner(PlannerGlobal *glob, Query *parse, char *plan_name, PlannerInfo *parent_root, bool hasRecursion, double tuple_fraction, SetOperationStmt *setops)
Path * get_cheapest_fractional_path(RelOptInfo *rel, double tuple_fraction)
bool limit_needed(Query *parse)
@ MONOTONICFUNC_DECREASING
@ MONOTONICFUNC_INCREASING
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
void get_agg_clause_costs(PlannerInfo *root, AggSplit aggsplit, AggClauseCosts *costs)
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 * build_simple_grouped_rel(PlannerInfo *root, RelOptInfo *rel)
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, int result_relation, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno, bool *outer_hasSubLinks)
@ REPLACEVARS_REPORT_ERROR
double estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows, List **pgset, EstimationInfo *estinfo)
void check_stack_depth(void)
struct Path * non_recursive_path
struct TableSampleClause * tablesample
struct PathTarget * agg_input
struct PathTarget * target
bool consider_param_startup
struct PathTarget * reltarget
struct RelAggInfo * agg_info
struct Path * cheapest_startup_path
struct Path * cheapest_total_path
struct RelOptInfo * grouped_rel
bool consider_partitionwise_join
WindowClause * window_clause
MonotonicFunction monotonic
bool repeatable_across_scans
SampleScanGetSampleSize_function SampleScanGetSampleSize
unsigned char * unsafeFlags
#define FirstLowInvalidHeapAttributeNumber
TsmRoutine * GetTsmRoutine(Oid tsmhandler)
bool create_tidscan_paths(PlannerInfo *root, RelOptInfo *rel)
bool grouping_is_sortable(List *groupClause)
List * make_tlist_from_pathtarget(PathTarget *target)
bool grouping_is_hashable(List *groupClause)
List * pull_var_clause(Node *node, int flags)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)