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;
3555 Path *outer_path,
Path *inner_path,
3556 List *outersortkeys,
List *innersortkeys,
3557 int outer_presorted_keys,
3561 Cost startup_cost = 0;
3563 double outer_path_rows = outer_path->
rows;
3564 double inner_path_rows = inner_path->
rows;
3565 Cost inner_run_cost;
3578 if (outer_path_rows <= 0)
3579 outer_path_rows = 1;
3580 if (inner_path_rows <= 0)
3581 inner_path_rows = 1;
3594 if (mergeclauses && jointype !=
JOIN_FULL)
3604 opathkeys = outersortkeys ? outersortkeys : outer_path->
pathkeys;
3605 ipathkeys = innersortkeys ? innersortkeys : inner_path->
pathkeys;
3612 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation ||
3615 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
3621 outer_path->parent->relids))
3640 outerstartsel = 0.0;
3646 innerstartsel = 0.0;
3653 outerstartsel = innerstartsel = 0.0;
3654 outerendsel = innerendsel = 1.0;
3661 outer_skip_rows = rint(outer_path_rows * outerstartsel);
3662 inner_skip_rows = rint(inner_path_rows * innerstartsel);
3666 Assert(outer_skip_rows <= outer_rows);
3667 Assert(inner_skip_rows <= inner_rows);
3674 outerstartsel = outer_skip_rows / outer_path_rows;
3675 innerstartsel = inner_skip_rows / inner_path_rows;
3676 outerendsel = outer_rows / outer_path_rows;
3677 innerendsel = inner_rows / inner_path_rows;
3679 Assert(outerstartsel <= outerendsel);
3680 Assert(innerstartsel <= innerendsel);
3704 outer_presorted_keys,
3709 outer_path->pathtarget->width,
3722 outer_path->pathtarget->width,
3733 * (outerendsel - outerstartsel);
3742 * (outerendsel - outerstartsel);
3765 inner_path->pathtarget->width,
3774 * (innerendsel - innerstartsel);
3783 * (innerendsel - innerstartsel);
3799 workspace->
total_cost = startup_cost + run_cost + inner_run_cost;
3843 double inner_path_rows = inner_path->
rows;
3858 double mergejointuples,
3866 if (inner_path_rows <= 0)
3867 inner_path_rows = 1;
3870 if (path->
jpath.path.param_info)
3871 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3873 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3876 if (path->
jpath.path.parallel_workers > 0)
3880 path->
jpath.path.rows =
3941 rescannedtuples = 0;
3944 rescannedtuples = mergejointuples - inner_path_rows;
3946 if (rescannedtuples < 0)
3947 rescannedtuples = 0;
3955 rescanratio = 1.0 + (rescannedtuples / inner_rows);
3966 bare_inner_cost = inner_run_cost * rescanratio;
3981 mat_inner_cost = inner_run_cost +
4013 else if (innersortkeys ==
NIL &&
4030 inner_path->pathtarget->width) >
4038 run_cost += mat_inner_cost;
4040 run_cost += bare_inner_cost;
4049 startup_cost += merge_qual_cost.
startup;
4050 startup_cost += merge_qual_cost.
per_tuple *
4051 (outer_skip_rows + inner_skip_rows * rescanratio);
4053 ((outer_rows - outer_skip_rows) +
4054 (inner_rows - inner_skip_rows) * rescanratio);
4065 startup_cost += qp_qual_cost.
startup;
4067 run_cost += cpu_per_tuple * mergejointuples;
4070 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4071 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4073 path->
jpath.path.startup_cost = startup_cost;
4074 path->
jpath.path.total_cost = startup_cost + run_cost;
4092 foreach(lc, rinfo->scansel_cache)
4096 cache->
collation == pathkey->pk_eclass->ec_collation &&
4118 cache->
collation = pathkey->pk_eclass->ec_collation;
4126 rinfo->scansel_cache =
lappend(rinfo->scansel_cache, cache);
4163 Path *outer_path,
Path *inner_path,
4168 Cost startup_cost = 0;
4170 double outer_path_rows = outer_path->
rows;
4171 double inner_path_rows = inner_path->
rows;
4172 double inner_path_rows_total = inner_path_rows;
4177 size_t space_allowed;
4223 inner_path->pathtarget->width,
4241 double outerpages =
page_size(outer_path_rows,
4242 outer_path->pathtarget->width);
4243 double innerpages =
page_size(inner_path_rows,
4244 inner_path->pathtarget->width);
4255 workspace->
total_cost = startup_cost + run_cost;
4281 double outer_path_rows = outer_path->
rows;
4282 double inner_path_rows = inner_path->
rows;
4292 double hashjointuples;
4293 double virtualbuckets;
4302 if (path->
jpath.path.param_info)
4303 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
4305 path->
jpath.path.rows = path->
jpath.path.parent->rows;
4308 if (path->
jpath.path.parallel_workers > 0)
4312 path->
jpath.path.rows =
4323 virtualbuckets = (double) numbuckets * (
double) numbatches;
4337 innerbucketsize = 1.0 / virtualbuckets;
4344 innerbucketsize = 1.0;
4354 foreach(hcl, otherclauses)
4369 inner_path->parent->relids))
4372 thisbucketsize = restrictinfo->right_bucketsize;
4373 if (thisbucketsize < 0)
4379 &restrictinfo->right_mcvfreq,
4380 &restrictinfo->right_bucketsize);
4381 thisbucketsize = restrictinfo->right_bucketsize;
4383 thismcvfreq = restrictinfo->right_mcvfreq;
4388 inner_path->parent->relids));
4390 thisbucketsize = restrictinfo->left_bucketsize;
4391 if (thisbucketsize < 0)
4397 &restrictinfo->left_mcvfreq,
4398 &restrictinfo->left_bucketsize);
4399 thisbucketsize = restrictinfo->left_bucketsize;
4401 thismcvfreq = restrictinfo->left_mcvfreq;
4404 if (innerbucketsize > thisbucketsize)
4405 innerbucketsize = thisbucketsize;
4406 if (innermcvfreq > thismcvfreq)
4407 innermcvfreq = thismcvfreq;
4438 double outer_matched_rows;
4456 startup_cost += hash_qual_cost.
startup;
4457 run_cost += hash_qual_cost.
per_tuple * outer_matched_rows *
4458 clamp_row_est(inner_path_rows * innerbucketsize * inner_scan_frac) * 0.5;
4474 (outer_path_rows - outer_matched_rows) *
4479 hashjointuples = outer_path_rows - outer_matched_rows;
4481 hashjointuples = outer_matched_rows;
4495 startup_cost += hash_qual_cost.
startup;
4496 run_cost += hash_qual_cost.
per_tuple * outer_path_rows *
4513 startup_cost += qp_qual_cost.
startup;
4515 run_cost += cpu_per_tuple * hashjointuples;
4518 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4519 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4521 path->
jpath.path.startup_cost = startup_cost;
4522 path->
jpath.path.total_cost = startup_cost + run_cost;
4572 Cost plan_run_cost =
plan->total_cost -
plan->startup_cost;
4583 sp_cost.
per_tuple += 0.50 * plan_run_cost;
4628 Cost *rescan_startup_cost,
4629 Cost *rescan_total_cost)
4633 case T_FunctionScan:
4642 *rescan_startup_cost = 0;
4651 if (((
HashPath *) path)->num_batches == 1)
4654 *rescan_startup_cost = 0;
4655 *rescan_total_cost = path->total_cost - path->startup_cost;
4660 *rescan_startup_cost = path->startup_cost;
4661 *rescan_total_cost = path->total_cost;
4665 case T_WorkTableScan:
4675 path->pathtarget->width);
4678 if (nbytes > work_mem_bytes)
4681 double npages = ceil(nbytes / BLCKSZ);
4685 *rescan_startup_cost = 0;
4686 *rescan_total_cost = run_cost;
4702 path->pathtarget->width);
4705 if (nbytes > work_mem_bytes)
4708 double npages = ceil(nbytes / BLCKSZ);
4712 *rescan_startup_cost = 0;
4713 *rescan_total_cost = run_cost;
4719 rescan_startup_cost, rescan_total_cost);
4722 *rescan_startup_cost = path->startup_cost;
4723 *rescan_total_cost = path->total_cost;
4760 *cost = context.
total;
4778 *cost = context.
total;
4797 if (rinfo->eval_cost.startup < 0)
4809 if (rinfo->orclause)
4818 if (rinfo->pseudoconstant)
4824 rinfo->eval_cost = locContext.
total;
4944 &iofunc, &typioparam);
4949 &iofunc, &typisvarlena);
4971 foreach(lc, rcexpr->opnos)
4992 elog(
ERROR,
"cannot handle unplanned sub-select");
5126 foreach(l, restrictlist)
5131 joinquals =
lappend(joinquals, rinfo);
5135 joinquals = restrictlist;
5175 avgmatch = nselec * innerrel->
rows / jselec;
5177 avgmatch =
Max(1.0, avgmatch);
5200 Relids joinrelids = joinpath->path.parent->relids;
5210 if (innerpath->param_info == NULL)
5217 case T_IndexOnlyScan:
5218 indexclauses = ((
IndexPath *) innerpath)->indexclauses;
5220 case T_BitmapHeapScan:
5226 indexclauses = ((
IndexPath *) bmqual)->indexclauses;
5248 foreach(lc, innerpath->param_info->ppi_clauses)
5253 innerpath->parent->relids,
5315 tuples = selec * outer_tuples * inner_tuples;
5366 List *param_clauses)
5386 if (nrows > rel->
rows)
5450 List *restrict_clauses)
5472 if (nrows > rel->
rows)
5535 foreach(l, restrictlist)
5540 pushedquals =
lappend(pushedquals, rinfo);
5542 joinquals =
lappend(joinquals, rinfo);
5586 nrows = outer_rows * inner_rows * fkselec * jselec;
5590 nrows = outer_rows * inner_rows * fkselec * jselec;
5591 if (nrows < outer_rows)
5596 nrows = outer_rows * inner_rows * fkselec * jselec;
5597 if (nrows < outer_rows)
5599 if (nrows < inner_rows)
5604 nrows = outer_rows * fkselec * jselec;
5608 nrows = outer_rows * (1.0 - fkselec * jselec);
5613 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
5641 List **restrictlist)
5645 List *worklist = *restrictlist;
5649 foreach(lc,
root->fkey_list)
5662 ref_is_outer =
false;
5665 ref_is_outer =
true;
5691 if (worklist == *restrictlist)
5695 foreach(cell, worklist)
5698 bool remove_it =
false;
5702 for (
i = 0;
i < fkinfo->
nkeys;
i++)
5704 if (rinfo->parent_ec)
5719 if (fkinfo->
eclass[
i] == rinfo->parent_ec)
5741 removedlist =
lappend(removedlist, rinfo);
5771 if (removedlist ==
NIL ||
5816 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5818 fkselec *= ref_rel->
rows / ref_tuples;
5828 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5830 fkselec *= 1.0 / ref_tuples;
5845 for (
int i = 0;
i < fkinfo->
nkeys;
i++)
5873 *restrictlist = worklist;
5916 int32 item_width = 0;
5947 Var *var = (
Var *) texpr;
6070 if (rte->self_reference)
6114 rel->
tuples = rte->enrtuples;
6199 int64 tuple_width = 0;
6200 bool have_wholerow_var =
false;
6218 ((
Var *) node)->varno == rel->
relid)
6235 have_wholerow_var =
true;
6243 if (rel->attr_widths[ndx] > 0)
6245 tuple_width += rel->attr_widths[ndx];
6255 rel->attr_widths[ndx] = item_width;
6256 tuple_width += item_width;
6267 rel->attr_widths[ndx] = item_width;
6268 tuple_width += item_width;
6297 tuple_width += item_width;
6309 if (have_wholerow_var)
6325 wholerow_width += rel->attr_widths[
i - rel->
min_attr];
6334 tuple_width += wholerow_width;
6355 int64 tuple_width = 0;
6362 foreach(lc, target->
exprs)
6397 const Var *var = (
const Var *) expr;
6404 var->
varno <
root->simple_rel_array_size)
6414 if (rel->attr_widths[ndx] > 0)
6415 return rel->attr_widths[ndx];
6477 double leader_contribution;
6480 if (leader_contribution > 0)
6481 parallel_divisor += leader_contribution;
6484 return parallel_divisor;
6501 Path *bitmapqual,
double loop_count,
6502 Cost *cost_p,
double *tuples_p)
6504 Cost indexTotalCost;
6507 double pages_fetched;
6508 double tuples_fetched;
6523 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
6530 pages_fetched = (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
6540 heap_pages =
Min(pages_fetched, baserel->
pages);
6555 pages_fetched /= loop_count;
6558 if (pages_fetched >=
T)
6561 pages_fetched = ceil(pages_fetched);
6563 if (maxentries < heap_pages)
6575 lossy_pages =
Max(0, heap_pages - maxentries / 2);
6576 exact_pages = heap_pages - lossy_pages;
6585 if (lossy_pages > 0)
6588 (exact_pages / heap_pages) * baserel->
tuples +
6589 (lossy_pages / heap_pages) * baserel->
tuples);
6593 *cost_p = indexTotalCost;
6595 *tuples_p = tuples_fetched;
6597 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 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)
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 initial_cost_mergejoin(PlannerInfo *root, JoinCostWorkspace *workspace, JoinType jointype, List *mergeclauses, Path *outer_path, Path *inner_path, List *outersortkeys, List *innersortkeys, int outer_presorted_keys, JoinPathExtraData *extra)
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_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)