113#define LOG2(x) (log(x) / 0.693147180559945)
120#define APPEND_CPU_COST_MULTIPLIER 0.5
128#define MAXIMUM_ROWCOUNT 1e100
178 Cost *rescan_startup_cost,
Cost *rescan_total_cost);
198 List **restrictlist);
200 int parallel_workers);
204static double page_size(
double tuples,
int width);
223 else if (nrows <= 1.0)
257 return (
int32) tuple_width;
283 return (
x < (
double) LONG_MAX) ? (long)
x : LONG_MAX;
298 Cost startup_cost = 0;
301 double spc_seq_page_cost;
323 disk_run_cost = spc_seq_page_cost * baserel->
pages;
328 startup_cost += qpqual_cost.
startup;
330 cpu_run_cost = cpu_per_tuple * baserel->
tuples;
332 startup_cost += path->pathtarget->cost.startup;
333 cpu_run_cost += path->pathtarget->cost.per_tuple * path->
rows;
341 cpu_run_cost /= parallel_divisor;
359 path->
total_cost = startup_cost + cpu_run_cost + disk_run_cost;
373 Cost startup_cost = 0;
378 double spc_seq_page_cost,
379 spc_random_page_cost,
400 &spc_random_page_cost,
405 spc_random_page_cost : spc_seq_page_cost;
411 run_cost += spc_page_cost * baserel->
pages;
423 startup_cost += qpqual_cost.
startup;
425 run_cost += cpu_per_tuple * baserel->
tuples;
427 startup_cost += path->pathtarget->cost.startup;
428 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
450 Cost startup_cost = 0;
487 int input_disabled_nodes,
488 Cost input_startup_cost,
Cost input_total_cost,
491 Cost startup_cost = 0;
493 Cost comparison_cost;
518 startup_cost += comparison_cost * N * logN;
521 run_cost += path->
path.
rows * comparison_cost * logN;
538 path->
path.
total_cost = (startup_cost + run_cost + input_total_cost);
565 bool indexonly = (path->
path.
pathtype == T_IndexOnlyScan);
568 Cost startup_cost = 0;
570 Cost cpu_run_cost = 0;
571 Cost indexStartupCost;
574 double indexCorrelation,
576 double spc_seq_page_cost,
577 spc_random_page_cost;
582 double tuples_fetched;
583 double pages_fetched;
584 double rand_heap_pages;
600 if (path->
path.param_info)
628 amcostestimate(
root, path, loop_count,
629 &indexStartupCost, &indexTotalCost,
630 &indexSelectivity, &indexCorrelation,
642 startup_cost += indexStartupCost;
643 run_cost += indexTotalCost - indexStartupCost;
650 &spc_random_page_cost,
692 (
double)
index->pages,
696 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
698 rand_heap_pages = pages_fetched;
700 max_IO_cost = (pages_fetched * spc_random_page_cost) / loop_count;
712 pages_fetched = ceil(indexSelectivity * (
double) baserel->
pages);
716 (
double)
index->pages,
720 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
722 min_IO_cost = (pages_fetched * spc_random_page_cost) / loop_count;
732 (
double)
index->pages,
736 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
738 rand_heap_pages = pages_fetched;
741 max_IO_cost = pages_fetched * spc_random_page_cost;
744 pages_fetched = ceil(indexSelectivity * (
double) baserel->
pages);
747 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
749 if (pages_fetched > 0)
751 min_IO_cost = spc_random_page_cost;
752 if (pages_fetched > 1)
753 min_IO_cost += (pages_fetched - 1) * spc_seq_page_cost;
767 rand_heap_pages = -1;
795 csquared = indexCorrelation * indexCorrelation;
797 run_cost += max_IO_cost + csquared * (min_IO_cost - max_IO_cost);
807 startup_cost += qpqual_cost.
startup;
810 cpu_run_cost += cpu_per_tuple * tuples_fetched;
813 startup_cost += path->
path.pathtarget->cost.startup;
814 cpu_run_cost += path->
path.pathtarget->cost.per_tuple * path->
path.
rows;
824 cpu_run_cost /= parallel_divisor;
827 run_cost += cpu_run_cost;
855 foreach(lc, qual_clauses)
859 if (rinfo->pseudoconstant)
864 result =
lappend(result, rinfo);
911 double pages_fetched;
917 T = (pages > 1) ? (
double) pages : 1.0;
920 total_pages =
root->total_table_pages + index_pages;
921 total_pages =
Max(total_pages, 1.0);
937 (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
938 if (pages_fetched >=
T)
941 pages_fetched = ceil(pages_fetched);
947 lim = (2.0 *
T *
b) / (2.0 *
T -
b);
948 if (tuples_fetched <= lim)
951 (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
956 b + (tuples_fetched - lim) * (
T -
b) /
T;
958 pages_fetched = ceil(pages_fetched);
960 return pages_fetched;
1025 Path *bitmapqual,
double loop_count)
1027 Cost startup_cost = 0;
1029 Cost indexTotalCost;
1034 double tuples_fetched;
1035 double pages_fetched;
1036 double spc_seq_page_cost,
1037 spc_random_page_cost;
1052 loop_count, &indexTotalCost,
1055 startup_cost += indexTotalCost;
1056 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
1060 &spc_random_page_cost,
1061 &spc_seq_page_cost);
1070 if (pages_fetched >= 2.0)
1071 cost_per_page = spc_random_page_cost -
1072 (spc_random_page_cost - spc_seq_page_cost)
1073 * sqrt(pages_fetched /
T);
1075 cost_per_page = spc_random_page_cost;
1077 run_cost += pages_fetched * cost_per_page;
1090 startup_cost += qpqual_cost.
startup;
1092 cpu_run_cost = cpu_per_tuple * tuples_fetched;
1100 cpu_run_cost /= parallel_divisor;
1106 run_cost += cpu_run_cost;
1109 startup_cost += path->pathtarget->cost.startup;
1110 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1126 *cost = ((
IndexPath *) path)->indextotalcost;
1127 *selec = ((
IndexPath *) path)->indexselectivity;
1192 totalCost += subCost;
1238 totalCost += subCost;
1261 Cost startup_cost = 0;
1268 double spc_random_page_cost;
1283 foreach(l, tidquals)
1324 &spc_random_page_cost,
1328 run_cost += spc_random_page_cost * ntuples;
1337 run_cost += cpu_per_tuple * ntuples;
1340 startup_cost += path->pathtarget->cost.startup;
1341 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1369 Cost startup_cost = 0;
1376 double spc_random_page_cost;
1377 double spc_seq_page_cost;
1392 pages = ceil(selectivity * baserel->
pages);
1405 ntuples = selectivity * baserel->
tuples;
1406 nseqpages = pages - 1.0;
1416 &spc_random_page_cost,
1417 &spc_seq_page_cost);
1420 run_cost += spc_random_page_cost + spc_seq_page_cost * nseqpages;
1435 run_cost += cpu_per_tuple * ntuples;
1438 startup_cost += path->pathtarget->cost.startup;
1439 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1459 bool trivial_pathtarget)
1513 if (qpquals ==
NIL && trivial_pathtarget)
1518 startup_cost = qpqual_cost.
startup;
1523 startup_cost += path->
path.pathtarget->cost.startup;
1524 run_cost += path->
path.pathtarget->cost.per_tuple * path->
path.
rows;
1541 Cost startup_cost = 0;
1579 startup_cost += qpqual_cost.
startup;
1581 run_cost += cpu_per_tuple * baserel->
tuples;
1584 startup_cost += path->pathtarget->cost.startup;
1585 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1603 Cost startup_cost = 0;
1636 startup_cost += qpqual_cost.
startup;
1638 run_cost += cpu_per_tuple * baserel->
tuples;
1641 startup_cost += path->pathtarget->cost.startup;
1642 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1660 Cost startup_cost = 0;
1684 startup_cost += qpqual_cost.
startup;
1686 run_cost += cpu_per_tuple * baserel->
tuples;
1689 startup_cost += path->pathtarget->cost.startup;
1690 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1711 Cost startup_cost = 0;
1732 startup_cost += qpqual_cost.
startup;
1734 run_cost += cpu_per_tuple * baserel->
tuples;
1737 startup_cost += path->pathtarget->cost.startup;
1738 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1753 Cost startup_cost = 0;
1774 startup_cost += qpqual_cost.
startup;
1776 run_cost += cpu_per_tuple * baserel->
tuples;
1791 Cost startup_cost = 0;
1809 startup_cost += qpqual_cost.
startup;
1811 run_cost += cpu_per_tuple * baserel->
tuples;
1835 total_rows = nrterm->
rows;
1844 total_rows += 10 * rterm->
rows;
1856 runion->
rows = total_rows;
1857 runion->pathtarget->width =
Max(nrterm->pathtarget->width,
1858 rterm->pathtarget->width);
1899 double tuples,
int width,
1900 Cost comparison_cost,
int sort_mem,
1901 double limit_tuples)
1904 double output_bytes;
1905 double output_tuples;
1906 int64 sort_mem_bytes = sort_mem * (
int64) 1024;
1919 if (limit_tuples > 0 && limit_tuples < tuples)
1921 output_tuples = limit_tuples;
1926 output_tuples = tuples;
1927 output_bytes = input_bytes;
1930 if (output_bytes > sort_mem_bytes)
1935 double npages = ceil(input_bytes / BLCKSZ);
1936 double nruns = input_bytes / sort_mem_bytes;
1939 double npageaccesses;
1946 *startup_cost = comparison_cost * tuples *
LOG2(tuples);
1951 if (nruns > mergeorder)
1952 log_runs = ceil(log(nruns) / log(mergeorder));
1955 npageaccesses = 2.0 * npages * log_runs;
1957 *startup_cost += npageaccesses *
1960 else if (tuples > 2 * output_tuples || input_bytes > sort_mem_bytes)
1968 *startup_cost = comparison_cost * tuples *
LOG2(2.0 * output_tuples);
1973 *startup_cost = comparison_cost * tuples *
LOG2(tuples);
2002 int input_disabled_nodes,
2003 Cost input_startup_cost,
Cost input_total_cost,
2004 double input_tuples,
int width,
Cost comparison_cost,
int sort_mem,
2005 double limit_tuples)
2009 input_run_cost = input_total_cost - input_startup_cost;
2010 double group_tuples,
2012 Cost group_startup_cost,
2014 group_input_run_cost;
2017 bool unknown_varno =
false;
2025 if (input_tuples < 2.0)
2053 foreach(l, pathkeys)
2065 unknown_varno =
true;
2081 group_tuples = input_tuples / input_groups;
2082 group_input_run_cost = input_run_cost / input_groups;
2089 group_tuples, width, comparison_cost, sort_mem,
2096 startup_cost = group_startup_cost + input_startup_cost +
2097 group_input_run_cost;
2105 run_cost = group_run_cost + (group_run_cost + group_startup_cost) *
2106 (input_groups - 1) + group_input_run_cost * (input_groups - 1);
2121 path->
rows = input_tuples;
2145 List *pathkeys,
int input_disabled_nodes,
2146 Cost input_cost,
double tuples,
int width,
2147 Cost comparison_cost,
int sort_mem,
2148 double limit_tuples)
2156 comparison_cost, sort_mem,
2159 startup_cost += input_cost;
2161 path->
rows = tuples;
2191 arrlen =
Min(parallel_workers, numpaths);
2196 foreach(cell, subpaths)
2200 if (path_index == arrlen)
2202 costarr[path_index++] =
subpath->total_cost;
2209 min_index = arrlen - 1;
2220 if (path_index++ == numpaths)
2223 costarr[min_index] +=
subpath->total_cost;
2227 for (
int i = 0;
i < arrlen;
i++)
2229 if (costarr[
i] < costarr[min_index])
2236 for (
int i = 0;
i < arrlen;
i++)
2238 if (costarr[
i] > costarr[max_index])
2242 return costarr[max_index];
2266 if (pathkeys ==
NIL)
2362 else if (i < apath->path.parallel_workers)
2373 if (i < apath->first_partial_path)
2377 double subpath_parallel_divisor;
2433 List *pathkeys,
int n_streams,
2434 int input_disabled_nodes,
2435 Cost input_startup_cost,
Cost input_total_cost,
2438 Cost startup_cost = 0;
2440 Cost comparison_cost;
2447 N = (n_streams < 2) ? 2.0 : (
double) n_streams;
2454 startup_cost += comparison_cost * N * logN;
2457 run_cost += tuples * comparison_cost * logN;
2466 path->
startup_cost = startup_cost + input_startup_cost;
2467 path->
total_cost = startup_cost + run_cost + input_total_cost;
2484 int input_disabled_nodes,
2485 Cost input_startup_cost,
Cost input_total_cost,
2486 double tuples,
int width)
2488 Cost startup_cost = input_startup_cost;
2489 Cost run_cost = input_total_cost - input_startup_cost;
2493 path->
rows = tuples;
2515 if (nbytes > work_mem_bytes)
2517 double npages = ceil(nbytes / BLCKSZ);
2542 Cost *rescan_startup_cost,
Cost *rescan_total_cost)
2549 double calls = mpath->
calls;
2550 int width = mpath->
subpath->pathtarget->width;
2552 double hash_mem_bytes;
2553 double est_entry_bytes;
2554 double est_cache_entries;
2578 est_cache_entries = floor(hash_mem_bytes / est_entry_bytes);
2613 evict_ratio = 1.0 -
Min(est_cache_entries, ndistinct) / ndistinct;
2621 hit_ratio = ((calls - ndistinct) / calls) *
2622 (est_cache_entries /
Max(ndistinct, est_cache_entries));
2624 Assert(hit_ratio >= 0 && hit_ratio <= 1.0);
2658 startup_cost = input_startup_cost * (1.0 - hit_ratio);
2666 *rescan_startup_cost = startup_cost;
2667 *rescan_total_cost = total_cost;
2684 int numGroupCols,
double numGroups,
2687 Cost input_startup_cost,
Cost input_total_cost,
2688 double input_tuples,
double input_width)
2690 double output_tuples;
2696 if (aggcosts == NULL)
2699 aggcosts = &dummy_aggcosts;
2726 startup_cost = input_total_cost;
2738 startup_cost = input_startup_cost;
2739 total_cost = input_total_cost;
2749 output_tuples = numGroups;
2754 startup_cost = input_total_cost;
2763 total_cost = startup_cost;
2767 output_tuples = numGroups;
2786 double pages_written = 0.0;
2787 double pages_read = 0.0;
2789 double hashentrysize;
2805 &ngroups_limit, &num_partitions);
2807 nbatches =
Max((numGroups * hashentrysize) / mem_limit,
2808 numGroups / ngroups_limit);
2810 nbatches =
Max(ceil(nbatches), 1.0);
2811 num_partitions =
Max(num_partitions, 2);
2818 depth = ceil(log(nbatches) / log(num_partitions));
2825 pages_written = pages_read = pages * depth;
2832 pages_written *= 2.0;
2840 startup_cost += spill_cost;
2841 total_cost += spill_cost;
2853 startup_cost += qual_cost.
startup;
2864 path->
rows = output_tuples;
2885 double input_tuples)
2888 double partition_tuples;
2889 double return_tuples;
2898 double num_partitions;
2900 root->parse->targetList);
2906 partition_tuples = input_tuples / num_partitions;
2911 partition_tuples = input_tuples;
2921 root->parse->targetList);
2925 partition_tuples, NULL,
2928 peer_tuples = partition_tuples / num_groups;
2939 return_tuples = partition_tuples;
2946 return_tuples = 1.0;
2956 return_tuples = partition_tuples;
2958 return_tuples = peer_tuples;
2967 return_tuples = 1.0;
2978 return_tuples = 1.0;
2983 double end_offset_value;
2988 if (endOffset->constisnull)
2997 end_offset_value = 1.0;
3017 partition_tuples / peer_tuples *
3036 return_tuples = end_offset_value + 1.0;
3041 return_tuples = peer_tuples * (end_offset_value + 1.0);
3050 return_tuples = 1.0;
3060 return_tuples = 1.0;
3070 return_tuples =
Min(return_tuples + 1.0, partition_tuples);
3078 return_tuples =
Min(return_tuples, partition_tuples);
3100 int input_disabled_nodes,
3101 Cost input_startup_cost,
Cost input_total_cost,
3102 double input_tuples)
3106 double startup_tuples;
3114 startup_cost = input_startup_cost;
3115 total_cost = input_total_cost;
3126 foreach(lc, windowFuncs)
3135 startup_cost += argcosts.
startup;
3140 startup_cost += argcosts.
startup;
3148 startup_cost += argcosts.
startup;
3151 total_cost += wfunccost * input_tuples;
3165 path->
rows = input_tuples;
3181 if (startup_tuples > 1.0)
3182 path->
startup_cost += (total_cost - startup_cost) / input_tuples *
3183 (startup_tuples - 1.0);
3196 int numGroupCols,
double numGroups,
3198 int input_disabled_nodes,
3199 Cost input_startup_cost,
Cost input_total_cost,
3200 double input_tuples)
3202 double output_tuples;
3206 output_tuples = numGroups;
3207 startup_cost = input_startup_cost;
3208 total_cost = input_total_cost;
3225 startup_cost += qual_cost.
startup;
3236 path->
rows = output_tuples;
3269 Path *outer_path,
Path *inner_path,
3273 Cost startup_cost = 0;
3275 double outer_path_rows = outer_path->
rows;
3276 Cost inner_rescan_start_cost;
3277 Cost inner_rescan_total_cost;
3278 Cost inner_run_cost;
3279 Cost inner_rescan_run_cost;
3288 &inner_rescan_start_cost,
3289 &inner_rescan_total_cost);
3301 if (outer_path_rows > 1)
3302 run_cost += (outer_path_rows - 1) * inner_rescan_start_cost;
3305 inner_rescan_run_cost = inner_rescan_total_cost - inner_rescan_start_cost;
3325 run_cost += inner_run_cost;
3326 if (outer_path_rows > 1)
3327 run_cost += (outer_path_rows - 1) * inner_rescan_run_cost;
3335 workspace->
total_cost = startup_cost + run_cost;
3355 double outer_path_rows = outer_path->
rows;
3356 double inner_path_rows = inner_path->
rows;
3367 if (outer_path_rows <= 0)
3368 outer_path_rows = 1;
3369 if (inner_path_rows <= 0)
3370 inner_path_rows = 1;
3372 if (path->
jpath.path.param_info)
3373 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3375 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3378 if (path->
jpath.path.parallel_workers > 0)
3382 path->
jpath.path.rows =
3397 double outer_matched_rows;
3398 double outer_unmatched_rows;
3411 outer_unmatched_rows = outer_path_rows - outer_matched_rows;
3418 ntuples = outer_matched_rows * inner_path_rows * inner_scan_frac;
3445 run_cost += inner_run_cost * inner_scan_frac;
3446 if (outer_matched_rows > 1)
3447 run_cost += (outer_matched_rows - 1) * inner_rescan_run_cost * inner_scan_frac;
3455 run_cost += outer_unmatched_rows *
3456 inner_rescan_run_cost / inner_path_rows;
3479 ntuples += outer_unmatched_rows * inner_path_rows;
3482 run_cost += inner_run_cost;
3483 if (outer_unmatched_rows >= 1)
3484 outer_unmatched_rows -= 1;
3486 outer_matched_rows -= 1;
3489 if (outer_matched_rows > 0)
3490 run_cost += outer_matched_rows * inner_rescan_run_cost * inner_scan_frac;
3493 if (outer_unmatched_rows > 0)
3494 run_cost += outer_unmatched_rows * inner_rescan_run_cost;
3502 ntuples = outer_path_rows * inner_path_rows;
3507 startup_cost += restrict_qual_cost.
startup;
3509 run_cost += cpu_per_tuple * ntuples;
3512 startup_cost += path->
jpath.path.pathtarget->cost.startup;
3513 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
3515 path->
jpath.path.startup_cost = startup_cost;
3516 path->
jpath.path.total_cost = startup_cost + run_cost;
3554 Path *outer_path,
Path *inner_path,
3555 List *outersortkeys,
List *innersortkeys,
3559 Cost startup_cost = 0;
3561 double outer_path_rows = outer_path->
rows;
3562 double inner_path_rows = inner_path->
rows;
3563 Cost inner_run_cost;
3576 if (outer_path_rows <= 0)
3577 outer_path_rows = 1;
3578 if (inner_path_rows <= 0)
3579 inner_path_rows = 1;
3592 if (mergeclauses && jointype !=
JOIN_FULL)
3602 opathkeys = outersortkeys ? outersortkeys : outer_path->
pathkeys;
3603 ipathkeys = innersortkeys ? innersortkeys : inner_path->
pathkeys;
3610 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation ||
3613 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
3619 outer_path->parent->relids))
3638 outerstartsel = 0.0;
3644 innerstartsel = 0.0;
3651 outerstartsel = innerstartsel = 0.0;
3652 outerendsel = innerendsel = 1.0;
3659 outer_skip_rows = rint(outer_path_rows * outerstartsel);
3660 inner_skip_rows = rint(inner_path_rows * innerstartsel);
3664 Assert(outer_skip_rows <= outer_rows);
3665 Assert(inner_skip_rows <= inner_rows);
3672 outerstartsel = outer_skip_rows / outer_path_rows;
3673 innerstartsel = inner_skip_rows / inner_path_rows;
3674 outerendsel = outer_rows / outer_path_rows;
3675 innerendsel = inner_rows / inner_path_rows;
3677 Assert(outerstartsel <= outerendsel);
3678 Assert(innerstartsel <= innerendsel);
3686 bool use_incremental_sort =
false;
3702 if (presorted_keys > 0)
3703 use_incremental_sort =
true;
3706 if (!use_incremental_sort)
3714 outer_path->pathtarget->width,
3729 outer_path->pathtarget->width,
3739 * (outerendsel - outerstartsel);
3748 * (outerendsel - outerstartsel);
3764 inner_path->pathtarget->width,
3773 * (innerendsel - innerstartsel);
3782 * (innerendsel - innerstartsel);
3798 workspace->
total_cost = startup_cost + run_cost + inner_run_cost;
3842 double inner_path_rows = inner_path->
rows;
3857 double mergejointuples,
3865 if (inner_path_rows <= 0)
3866 inner_path_rows = 1;
3869 if (path->
jpath.path.param_info)
3870 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3872 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3875 if (path->
jpath.path.parallel_workers > 0)
3879 path->
jpath.path.rows =
3940 rescannedtuples = 0;
3943 rescannedtuples = mergejointuples - inner_path_rows;
3945 if (rescannedtuples < 0)
3946 rescannedtuples = 0;
3954 rescanratio = 1.0 + (rescannedtuples / inner_rows);
3965 bare_inner_cost = inner_run_cost * rescanratio;
3980 mat_inner_cost = inner_run_cost +
4012 else if (innersortkeys ==
NIL &&
4029 inner_path->pathtarget->width) >
4037 run_cost += mat_inner_cost;
4039 run_cost += bare_inner_cost;
4048 startup_cost += merge_qual_cost.
startup;
4049 startup_cost += merge_qual_cost.
per_tuple *
4050 (outer_skip_rows + inner_skip_rows * rescanratio);
4052 ((outer_rows - outer_skip_rows) +
4053 (inner_rows - inner_skip_rows) * rescanratio);
4064 startup_cost += qp_qual_cost.
startup;
4066 run_cost += cpu_per_tuple * mergejointuples;
4069 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4070 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4072 path->
jpath.path.startup_cost = startup_cost;
4073 path->
jpath.path.total_cost = startup_cost + run_cost;
4091 foreach(lc, rinfo->scansel_cache)
4095 cache->
collation == pathkey->pk_eclass->ec_collation &&
4117 cache->
collation = pathkey->pk_eclass->ec_collation;
4125 rinfo->scansel_cache =
lappend(rinfo->scansel_cache, cache);
4162 Path *outer_path,
Path *inner_path,
4167 Cost startup_cost = 0;
4169 double outer_path_rows = outer_path->
rows;
4170 double inner_path_rows = inner_path->
rows;
4171 double inner_path_rows_total = inner_path_rows;
4176 size_t space_allowed;
4222 inner_path->pathtarget->width,
4240 double outerpages =
page_size(outer_path_rows,
4241 outer_path->pathtarget->width);
4242 double innerpages =
page_size(inner_path_rows,
4243 inner_path->pathtarget->width);
4254 workspace->
total_cost = startup_cost + run_cost;
4280 double outer_path_rows = outer_path->
rows;
4281 double inner_path_rows = inner_path->
rows;
4291 double hashjointuples;
4292 double virtualbuckets;
4301 if (path->
jpath.path.param_info)
4302 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
4304 path->
jpath.path.rows = path->
jpath.path.parent->rows;
4307 if (path->
jpath.path.parallel_workers > 0)
4311 path->
jpath.path.rows =
4322 virtualbuckets = (double) numbuckets * (
double) numbatches;
4336 innerbucketsize = 1.0 / virtualbuckets;
4343 innerbucketsize = 1.0;
4353 foreach(hcl, otherclauses)
4368 inner_path->parent->relids))
4371 thisbucketsize = restrictinfo->right_bucketsize;
4372 if (thisbucketsize < 0)
4378 &restrictinfo->right_mcvfreq,
4379 &restrictinfo->right_bucketsize);
4380 thisbucketsize = restrictinfo->right_bucketsize;
4382 thismcvfreq = restrictinfo->right_mcvfreq;
4387 inner_path->parent->relids));
4389 thisbucketsize = restrictinfo->left_bucketsize;
4390 if (thisbucketsize < 0)
4396 &restrictinfo->left_mcvfreq,
4397 &restrictinfo->left_bucketsize);
4398 thisbucketsize = restrictinfo->left_bucketsize;
4400 thismcvfreq = restrictinfo->left_mcvfreq;
4403 if (innerbucketsize > thisbucketsize)
4404 innerbucketsize = thisbucketsize;
4405 if (innermcvfreq > thismcvfreq)
4406 innermcvfreq = thismcvfreq;
4437 double outer_matched_rows;
4455 startup_cost += hash_qual_cost.
startup;
4456 run_cost += hash_qual_cost.
per_tuple * outer_matched_rows *
4457 clamp_row_est(inner_path_rows * innerbucketsize * inner_scan_frac) * 0.5;
4473 (outer_path_rows - outer_matched_rows) *
4478 hashjointuples = outer_path_rows - outer_matched_rows;
4480 hashjointuples = outer_matched_rows;
4494 startup_cost += hash_qual_cost.
startup;
4495 run_cost += hash_qual_cost.
per_tuple * outer_path_rows *
4512 startup_cost += qp_qual_cost.
startup;
4514 run_cost += cpu_per_tuple * hashjointuples;
4517 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4518 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4520 path->
jpath.path.startup_cost = startup_cost;
4521 path->
jpath.path.total_cost = startup_cost + run_cost;
4571 Cost plan_run_cost =
plan->total_cost -
plan->startup_cost;
4582 sp_cost.
per_tuple += 0.50 * plan_run_cost;
4627 Cost *rescan_startup_cost,
4628 Cost *rescan_total_cost)
4632 case T_FunctionScan:
4641 *rescan_startup_cost = 0;
4650 if (((
HashPath *) path)->num_batches == 1)
4653 *rescan_startup_cost = 0;
4654 *rescan_total_cost = path->total_cost - path->startup_cost;
4659 *rescan_startup_cost = path->startup_cost;
4660 *rescan_total_cost = path->total_cost;
4664 case T_WorkTableScan:
4674 path->pathtarget->width);
4677 if (nbytes > work_mem_bytes)
4680 double npages = ceil(nbytes / BLCKSZ);
4684 *rescan_startup_cost = 0;
4685 *rescan_total_cost = run_cost;
4701 path->pathtarget->width);
4704 if (nbytes > work_mem_bytes)
4707 double npages = ceil(nbytes / BLCKSZ);
4711 *rescan_startup_cost = 0;
4712 *rescan_total_cost = run_cost;
4718 rescan_startup_cost, rescan_total_cost);
4721 *rescan_startup_cost = path->startup_cost;
4722 *rescan_total_cost = path->total_cost;
4759 *cost = context.
total;
4777 *cost = context.
total;
4796 if (rinfo->eval_cost.startup < 0)
4808 if (rinfo->orclause)
4817 if (rinfo->pseudoconstant)
4823 rinfo->eval_cost = locContext.
total;
4943 &iofunc, &typioparam);
4948 &iofunc, &typisvarlena);
4970 foreach(lc, rcexpr->opnos)
4991 elog(
ERROR,
"cannot handle unplanned sub-select");
5125 foreach(l, restrictlist)
5130 joinquals =
lappend(joinquals, rinfo);
5134 joinquals = restrictlist;
5174 avgmatch = nselec * innerrel->
rows / jselec;
5176 avgmatch =
Max(1.0, avgmatch);
5199 Relids joinrelids = joinpath->path.parent->relids;
5209 if (innerpath->param_info == NULL)
5216 case T_IndexOnlyScan:
5217 indexclauses = ((
IndexPath *) innerpath)->indexclauses;
5219 case T_BitmapHeapScan:
5225 indexclauses = ((
IndexPath *) bmqual)->indexclauses;
5247 foreach(lc, innerpath->param_info->ppi_clauses)
5252 innerpath->parent->relids,
5314 tuples = selec * outer_tuples * inner_tuples;
5365 List *param_clauses)
5385 if (nrows > rel->
rows)
5449 List *restrict_clauses)
5471 if (nrows > rel->
rows)
5534 foreach(l, restrictlist)
5539 pushedquals =
lappend(pushedquals, rinfo);
5541 joinquals =
lappend(joinquals, rinfo);
5585 nrows = outer_rows * inner_rows * fkselec * jselec;
5589 nrows = outer_rows * inner_rows * fkselec * jselec;
5590 if (nrows < outer_rows)
5595 nrows = outer_rows * inner_rows * fkselec * jselec;
5596 if (nrows < outer_rows)
5598 if (nrows < inner_rows)
5603 nrows = outer_rows * fkselec * jselec;
5607 nrows = outer_rows * (1.0 - fkselec * jselec);
5612 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
5640 List **restrictlist)
5644 List *worklist = *restrictlist;
5648 foreach(lc,
root->fkey_list)
5661 ref_is_outer =
false;
5664 ref_is_outer =
true;
5690 if (worklist == *restrictlist)
5694 foreach(cell, worklist)
5697 bool remove_it =
false;
5701 for (
i = 0;
i < fkinfo->
nkeys;
i++)
5703 if (rinfo->parent_ec)
5718 if (fkinfo->
eclass[
i] == rinfo->parent_ec)
5740 removedlist =
lappend(removedlist, rinfo);
5770 if (removedlist ==
NIL ||
5815 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5817 fkselec *= ref_rel->
rows / ref_tuples;
5827 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5829 fkselec *= 1.0 / ref_tuples;
5844 for (
int i = 0;
i < fkinfo->
nkeys;
i++)
5872 *restrictlist = worklist;
5915 int32 item_width = 0;
5946 Var *var = (
Var *) texpr;
6069 if (rte->self_reference)
6113 rel->
tuples = rte->enrtuples;
6198 int64 tuple_width = 0;
6199 bool have_wholerow_var =
false;
6217 ((
Var *) node)->varno == rel->
relid)
6234 have_wholerow_var =
true;
6242 if (rel->attr_widths[ndx] > 0)
6244 tuple_width += rel->attr_widths[ndx];
6254 rel->attr_widths[ndx] = item_width;
6255 tuple_width += item_width;
6266 rel->attr_widths[ndx] = item_width;
6267 tuple_width += item_width;
6296 tuple_width += item_width;
6308 if (have_wholerow_var)
6324 wholerow_width += rel->attr_widths[
i - rel->
min_attr];
6333 tuple_width += wholerow_width;
6354 int64 tuple_width = 0;
6361 foreach(lc, target->
exprs)
6396 const Var *var = (
const Var *) expr;
6403 var->
varno <
root->simple_rel_array_size)
6413 if (rel->attr_widths[ndx] > 0)
6414 return rel->attr_widths[ndx];
6476 double leader_contribution;
6479 if (leader_contribution > 0)
6480 parallel_divisor += leader_contribution;
6483 return parallel_divisor;
6500 Path *bitmapqual,
double loop_count,
6501 Cost *cost_p,
double *tuples_p)
6503 Cost indexTotalCost;
6506 double pages_fetched;
6507 double tuples_fetched;
6522 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
6529 pages_fetched = (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
6539 heap_pages =
Min(pages_fetched, baserel->
pages);
6554 pages_fetched /= loop_count;
6557 if (pages_fetched >=
T)
6560 pages_fetched = ceil(pages_fetched);
6562 if (maxentries < heap_pages)
6574 lossy_pages =
Max(0, heap_pages - maxentries / 2);
6575 exact_pages = heap_pages - lossy_pages;
6584 if (lossy_pages > 0)
6587 (exact_pages / heap_pages) * baserel->
tuples +
6588 (lossy_pages / heap_pages) * baserel->
tuples);
6592 *cost_p = indexTotalCost;
6594 *tuples_p = tuples_fetched;
6596 return pages_fetched;
int compute_parallel_worker(RelOptInfo *rel, double heap_pages, double index_pages, int max_workers)
void(* amcostestimate_function)(struct PlannerInfo *root, struct IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
bool bms_is_member(int x, const Bitmapset *a)
BMS_Membership bms_membership(const Bitmapset *a)
#define PG_USED_FOR_ASSERTS_ONLY
#define OidIsValid(objectId)
double expression_returns_set_rows(PlannerInfo *root, Node *clause)
Selectivity clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Selectivity clause_selectivity(PlannerInfo *root, Node *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
#define DEFAULT_PARALLEL_TUPLE_COST
#define DEFAULT_PARALLEL_SETUP_COST
#define DEFAULT_CPU_INDEX_TUPLE_COST
#define DEFAULT_CPU_TUPLE_COST
#define DEFAULT_RANDOM_PAGE_COST
#define DEFAULT_RECURSIVE_WORKTABLE_FACTOR
#define DEFAULT_EFFECTIVE_CACHE_SIZE
#define DEFAULT_SEQ_PAGE_COST
#define DEFAULT_CPU_OPERATOR_COST
#define APPEND_CPU_COST_MULTIPLIER
void set_namedtuplestore_size_estimates(PlannerInfo *root, RelOptInfo *rel)
static double get_windowclause_startup_tuples(PlannerInfo *root, WindowClause *wc, double input_tuples)
bool enable_partitionwise_aggregate
void final_cost_hashjoin(PlannerInfo *root, HashPath *path, JoinCostWorkspace *workspace, JoinPathExtraData *extra)
double index_pages_fetched(double tuples_fetched, BlockNumber pages, double index_pages, PlannerInfo *root)
void cost_bitmap_tree_node(Path *path, Cost *cost, Selectivity *selec)
double get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel, List *param_clauses)
static void get_restriction_qual_cost(PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info, QualCost *qpqual_cost)
static double page_size(double tuples, int width)
int max_parallel_workers_per_gather
double get_parameterized_joinrel_size(PlannerInfo *root, RelOptInfo *rel, Path *outer_path, Path *inner_path, SpecialJoinInfo *sjinfo, List *restrict_clauses)
void final_cost_mergejoin(PlannerInfo *root, MergePath *path, JoinCostWorkspace *workspace, JoinPathExtraData *extra)
static List * extract_nonindex_conditions(List *qual_clauses, List *indexclauses)
void initial_cost_mergejoin(PlannerInfo *root, JoinCostWorkspace *workspace, JoinType jointype, List *mergeclauses, Path *outer_path, Path *inner_path, List *outersortkeys, List *innersortkeys, JoinPathExtraData *extra)
static void set_rel_width(PlannerInfo *root, RelOptInfo *rel)
void compute_semi_anti_join_factors(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinType jointype, SpecialJoinInfo *sjinfo, List *restrictlist, SemiAntiJoinFactors *semifactors)
static double get_indexpath_pages(Path *bitmapqual)
double parallel_setup_cost
static bool cost_qual_eval_walker(Node *node, cost_qual_eval_context *context)
void set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void cost_windowagg(Path *path, PlannerInfo *root, List *windowFuncs, WindowClause *winclause, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double input_tuples)
double recursive_worktable_factor
void cost_functionscan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
void cost_material(Path *path, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double tuples, int width)
void cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info, Path *bitmapqual, double loop_count)
void cost_tidrangescan(Path *path, PlannerInfo *root, RelOptInfo *baserel, List *tidrangequals, ParamPathInfo *param_info)
static double relation_byte_size(double tuples, int width)
double parallel_tuple_cost
void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void cost_agg(Path *path, PlannerInfo *root, AggStrategy aggstrategy, const AggClauseCosts *aggcosts, int numGroupCols, double numGroups, List *quals, int disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double input_tuples, double input_width)
void cost_sort(Path *path, PlannerInfo *root, List *pathkeys, int input_disabled_nodes, Cost input_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
static double calc_joinrel_size_estimate(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, double outer_rows, double inner_rows, SpecialJoinInfo *sjinfo, List *restrictlist)
static MergeScanSelCache * cached_scansel(PlannerInfo *root, RestrictInfo *rinfo, PathKey *pathkey)
static void cost_rescan(PlannerInfo *root, Path *path, Cost *rescan_startup_cost, Cost *rescan_total_cost)
bool enable_indexonlyscan
void final_cost_nestloop(PlannerInfo *root, NestPath *path, JoinCostWorkspace *workspace, JoinPathExtraData *extra)
void cost_gather_merge(GatherMergePath *path, PlannerInfo *root, RelOptInfo *rel, ParamPathInfo *param_info, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double *rows)
void cost_recursive_union(Path *runion, Path *nrterm, Path *rterm)
static void cost_tuplesort(Cost *startup_cost, Cost *run_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
void cost_tablefuncscan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
void initial_cost_hashjoin(PlannerInfo *root, JoinCostWorkspace *workspace, JoinType jointype, List *hashclauses, Path *outer_path, Path *inner_path, JoinPathExtraData *extra, bool parallel_hash)
void cost_samplescan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
void cost_gather(GatherPath *path, PlannerInfo *root, RelOptInfo *rel, ParamPathInfo *param_info, double *rows)
void set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel, double cte_rows)
void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List *restrictlist)
double compute_gather_rows(Path *path)
void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root)
void cost_namedtuplestorescan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
void cost_seqscan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
PathTarget * set_pathtarget_cost_width(PlannerInfo *root, PathTarget *target)
void cost_valuesscan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
void cost_incremental_sort(Path *path, PlannerInfo *root, List *pathkeys, int presorted_keys, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double input_tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root)
bool enable_presorted_aggregate
void initial_cost_nestloop(PlannerInfo *root, JoinCostWorkspace *workspace, JoinType jointype, Path *outer_path, Path *inner_path, JoinPathExtraData *extra)
void set_result_size_estimates(PlannerInfo *root, RelOptInfo *rel)
static bool has_indexed_join_quals(NestPath *path)
bool enable_parallel_hash
bool enable_partitionwise_join
void cost_group(Path *path, PlannerInfo *root, int numGroupCols, double numGroups, List *quals, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double input_tuples)
void cost_resultscan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
static Cost append_nonpartial_cost(List *subpaths, int numpaths, int parallel_workers)
double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel, Path *bitmapqual, double loop_count, Cost *cost_p, double *tuples_p)
void cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root)
void set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel)
bool enable_parallel_append
void set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void cost_tidscan(Path *path, PlannerInfo *root, RelOptInfo *baserel, List *tidquals, ParamPathInfo *param_info)
static double approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
void cost_subplan(PlannerInfo *root, SubPlan *subplan, Plan *plan)
static void cost_memoize_rescan(PlannerInfo *root, MemoizePath *mpath, Cost *rescan_startup_cost, Cost *rescan_total_cost)
void cost_merge_append(Path *path, PlannerInfo *root, List *pathkeys, int n_streams, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double tuples)
double clamp_row_est(double nrows)
static double get_parallel_divisor(Path *path)
void cost_subqueryscan(SubqueryScanPath *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info, bool trivial_pathtarget)
void cost_append(AppendPath *apath)
void cost_ctescan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
long clamp_cardinality_to_long(Cardinality x)
void cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root)
bool enable_partition_pruning
int32 clamp_width_est(int64 tuple_width)
double cpu_index_tuple_cost
void set_tablefunc_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void cost_index(IndexPath *path, PlannerInfo *root, double loop_count, bool partial_path)
void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel)
static Selectivity get_foreign_key_join_selectivity(PlannerInfo *root, Relids outer_relids, Relids inner_relids, SpecialJoinInfo *sjinfo, List **restrictlist)
bool enable_incremental_sort
static int32 get_expr_width(PlannerInfo *root, const Node *expr)
bool is_redundant_with_indexclauses(RestrictInfo *rinfo, List *indexclauses)
RestrictInfo * find_derived_clause_for_ec_member(PlannerInfo *root, EquivalenceClass *ec, EquivalenceMember *em)
bool ExecSupportsMarkRestore(Path *pathnode)
bool ExecMaterializesOutput(NodeTag plantype)
Assert(PointerIsAligned(start, uint64))
#define SizeofHeapTupleHeader
if(TABLE==NULL||TABLE_index==NULL)
void init_dummy_sjinfo(SpecialJoinInfo *sjinfo, Relids left_relids, Relids right_relids)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
List * list_copy(const List *oldlist)
bool list_member_ptr(const List *list, const void *datum)
void list_free(List *list)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
int32 get_attavgwidth(Oid relid, AttrNumber attnum)
RegProcedure get_opcode(Oid opno)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
int32 get_typavgwidth(Oid typid, int32 typmod)
Datum subpath(PG_FUNCTION_ARGS)
List * make_ands_implicit(Expr *clause)
static const uint32 T[65]
Size hash_agg_entry_size(int numTrans, Size tupleWidth, Size transitionSpace)
void hash_agg_set_limits(double hashentrysize, double input_groups, int used_bits, Size *mem_limit, uint64 *ngroups_limit, int *num_partitions)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
void set_sa_opfuncid(ScalarArrayOpExpr *opexpr)
void set_opfuncid(OpExpr *opexpr)
static Node * get_rightop(const void *clause)
#define expression_tree_walker(n, w, c)
static Node * get_leftop(const void *clause)
void ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew, bool try_combined_hash_mem, int parallel_workers, size_t *space_allowed, int *numbuckets, int *numbatches, int *num_skew_mcvs)
size_t get_hash_memory_limit(void)
double ExecEstimateCacheEntryOverheadBytes(double ntuples)
#define IsA(nodeptr, _type_)
#define IS_OUTER_JOIN(jointype)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define FRAMEOPTION_END_CURRENT_ROW
#define FRAMEOPTION_END_OFFSET_PRECEDING
#define FRAMEOPTION_END_OFFSET_FOLLOWING
#define FRAMEOPTION_RANGE
#define FRAMEOPTION_GROUPS
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
bool pathkeys_count_contained_in(List *keys1, List *keys2, int *n_common)
bool pathkeys_contained_in(List *keys1, List *keys2)
#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids)
#define planner_rt_fetch(rti, root)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define foreach_current_index(var_or_cell)
#define foreach_delete_current(lst, var_or_cell)
#define for_each_cell(cell, lst, initcell)
static ListCell * list_head(const List *l)
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv)
void add_function_cost(PlannerInfo *root, Oid funcid, Node *node, QualCost *cost)
int32 get_relation_data_width(Oid relid, int32 *attr_widths)
bool parallel_leader_participation
static int64 DatumGetInt64(Datum X)
static int16 DatumGetInt16(Datum X)
static int32 DatumGetInt32(Datum X)
#define IS_SPECIAL_VARNO(varno)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
bool join_clause_is_movable_into(RestrictInfo *rinfo, Relids currentrelids, Relids current_and_outer)
void mergejoinscansel(PlannerInfo *root, Node *clause, Oid opfamily, CompareType cmptype, bool nulls_first, Selectivity *leftstart, Selectivity *leftend, Selectivity *rightstart, Selectivity *rightend)
double estimate_array_length(PlannerInfo *root, Node *arrayexpr)
double estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows, List **pgset, EstimationInfo *estinfo)
List * estimate_multivariate_bucketsize(PlannerInfo *root, RelOptInfo *inner, List *hashclauses, Selectivity *innerbucketsize)
void estimate_hash_bucket_stats(PlannerInfo *root, Node *hashkey, double nbuckets, Selectivity *mcv_freq, Selectivity *bucketsize_frac)
#define CLAMP_PROBABILITY(p)
#define DEFAULT_NUM_DISTINCT
#define SELFLAG_USED_DEFAULT
void get_tablespace_page_costs(Oid spcid, double *spc_random_page_cost, double *spc_seq_page_cost)
Selectivity bitmapselectivity
Selectivity bitmapselectivity
struct EquivalenceClass * eclass[INDEX_MAX_KEYS]
List * rinfos[INDEX_MAX_KEYS]
struct EquivalenceMember * fk_eclass_member[INDEX_MAX_KEYS]
Cardinality inner_rows_total
Selectivity indexselectivity
Cost inner_rescan_run_cost
Cardinality inner_skip_rows
Cardinality inner_rows_total
Cardinality outer_skip_rows
Selectivity rightstartsel
struct TableSampleClause * tablesample
struct PathTarget * reltarget
QualCost baserestrictcost
struct Path * cheapest_total_path
Selectivity outer_match_frac
NextSampleBlock_function NextSampleBlock
TsmRoutine * GetTsmRoutine(Oid tsmhandler)
int tbm_calculate_entries(Size maxbytes)
List * get_sortgrouplist_exprs(List *sgClauses, List *targetList)
int tuplesort_merge_order(int64 allowedMem)
Relids pull_varnos(PlannerInfo *root, Node *node)