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;
272 Cost startup_cost = 0;
275 double spc_seq_page_cost;
297 disk_run_cost = spc_seq_page_cost * baserel->
pages;
302 startup_cost += qpqual_cost.
startup;
304 cpu_run_cost = cpu_per_tuple * baserel->
tuples;
306 startup_cost += path->pathtarget->cost.startup;
307 cpu_run_cost += path->pathtarget->cost.per_tuple * path->
rows;
315 cpu_run_cost /= parallel_divisor;
333 path->
total_cost = startup_cost + cpu_run_cost + disk_run_cost;
347 Cost startup_cost = 0;
352 double spc_seq_page_cost,
353 spc_random_page_cost,
374 &spc_random_page_cost,
379 spc_random_page_cost : spc_seq_page_cost;
385 run_cost += spc_page_cost * baserel->
pages;
397 startup_cost += qpqual_cost.
startup;
399 run_cost += cpu_per_tuple * baserel->
tuples;
401 startup_cost += path->pathtarget->cost.startup;
402 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
424 Cost startup_cost = 0;
461 int input_disabled_nodes,
462 Cost input_startup_cost,
Cost input_total_cost,
465 Cost startup_cost = 0;
467 Cost comparison_cost;
492 startup_cost += comparison_cost * N * logN;
495 run_cost += path->
path.
rows * comparison_cost * logN;
512 path->
path.
total_cost = (startup_cost + run_cost + input_total_cost);
539 bool indexonly = (path->
path.
pathtype == T_IndexOnlyScan);
542 Cost startup_cost = 0;
544 Cost cpu_run_cost = 0;
545 Cost indexStartupCost;
548 double indexCorrelation,
550 double spc_seq_page_cost,
551 spc_random_page_cost;
556 double tuples_fetched;
557 double pages_fetched;
558 double rand_heap_pages;
574 if (path->
path.param_info)
602 amcostestimate(
root, path, loop_count,
603 &indexStartupCost, &indexTotalCost,
604 &indexSelectivity, &indexCorrelation,
616 startup_cost += indexStartupCost;
617 run_cost += indexTotalCost - indexStartupCost;
624 &spc_random_page_cost,
666 (
double)
index->pages,
670 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
672 rand_heap_pages = pages_fetched;
674 max_IO_cost = (pages_fetched * spc_random_page_cost) / loop_count;
686 pages_fetched = ceil(indexSelectivity * (
double) baserel->
pages);
690 (
double)
index->pages,
694 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
696 min_IO_cost = (pages_fetched * spc_random_page_cost) / loop_count;
706 (
double)
index->pages,
710 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
712 rand_heap_pages = pages_fetched;
715 max_IO_cost = pages_fetched * spc_random_page_cost;
718 pages_fetched = ceil(indexSelectivity * (
double) baserel->
pages);
721 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
723 if (pages_fetched > 0)
725 min_IO_cost = spc_random_page_cost;
726 if (pages_fetched > 1)
727 min_IO_cost += (pages_fetched - 1) * spc_seq_page_cost;
741 rand_heap_pages = -1;
769 csquared = indexCorrelation * indexCorrelation;
771 run_cost += max_IO_cost + csquared * (min_IO_cost - max_IO_cost);
781 startup_cost += qpqual_cost.
startup;
784 cpu_run_cost += cpu_per_tuple * tuples_fetched;
787 startup_cost += path->
path.pathtarget->cost.startup;
788 cpu_run_cost += path->
path.pathtarget->cost.per_tuple * path->
path.
rows;
798 cpu_run_cost /= parallel_divisor;
801 run_cost += cpu_run_cost;
829 foreach(lc, qual_clauses)
833 if (rinfo->pseudoconstant)
838 result =
lappend(result, rinfo);
885 double pages_fetched;
891 T = (pages > 1) ? (
double) pages : 1.0;
894 total_pages =
root->total_table_pages + index_pages;
895 total_pages =
Max(total_pages, 1.0);
911 (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
912 if (pages_fetched >=
T)
915 pages_fetched = ceil(pages_fetched);
921 lim = (2.0 *
T *
b) / (2.0 *
T -
b);
922 if (tuples_fetched <= lim)
925 (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
930 b + (tuples_fetched - lim) * (
T -
b) /
T;
932 pages_fetched = ceil(pages_fetched);
934 return pages_fetched;
999 Path *bitmapqual,
double loop_count)
1001 Cost startup_cost = 0;
1003 Cost indexTotalCost;
1008 double tuples_fetched;
1009 double pages_fetched;
1010 double spc_seq_page_cost,
1011 spc_random_page_cost;
1026 loop_count, &indexTotalCost,
1029 startup_cost += indexTotalCost;
1030 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
1034 &spc_random_page_cost,
1035 &spc_seq_page_cost);
1044 if (pages_fetched >= 2.0)
1045 cost_per_page = spc_random_page_cost -
1046 (spc_random_page_cost - spc_seq_page_cost)
1047 * sqrt(pages_fetched /
T);
1049 cost_per_page = spc_random_page_cost;
1051 run_cost += pages_fetched * cost_per_page;
1064 startup_cost += qpqual_cost.
startup;
1066 cpu_run_cost = cpu_per_tuple * tuples_fetched;
1074 cpu_run_cost /= parallel_divisor;
1080 run_cost += cpu_run_cost;
1083 startup_cost += path->pathtarget->cost.startup;
1084 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1100 *cost = ((
IndexPath *) path)->indextotalcost;
1101 *selec = ((
IndexPath *) path)->indexselectivity;
1166 totalCost += subCost;
1212 totalCost += subCost;
1235 Cost startup_cost = 0;
1242 double spc_random_page_cost;
1257 foreach(l, tidquals)
1298 &spc_random_page_cost,
1302 run_cost += spc_random_page_cost * ntuples;
1311 run_cost += cpu_per_tuple * ntuples;
1314 startup_cost += path->pathtarget->cost.startup;
1315 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1343 Cost startup_cost = 0;
1350 double spc_random_page_cost;
1351 double spc_seq_page_cost;
1366 pages = ceil(selectivity * baserel->
pages);
1379 ntuples = selectivity * baserel->
tuples;
1380 nseqpages = pages - 1.0;
1390 &spc_random_page_cost,
1391 &spc_seq_page_cost);
1394 run_cost += spc_random_page_cost + spc_seq_page_cost * nseqpages;
1409 run_cost += cpu_per_tuple * ntuples;
1412 startup_cost += path->pathtarget->cost.startup;
1413 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1433 bool trivial_pathtarget)
1487 if (qpquals ==
NIL && trivial_pathtarget)
1492 startup_cost = qpqual_cost.
startup;
1497 startup_cost += path->
path.pathtarget->cost.startup;
1498 run_cost += path->
path.pathtarget->cost.per_tuple * path->
path.
rows;
1515 Cost startup_cost = 0;
1553 startup_cost += qpqual_cost.
startup;
1555 run_cost += cpu_per_tuple * baserel->
tuples;
1558 startup_cost += path->pathtarget->cost.startup;
1559 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1577 Cost startup_cost = 0;
1610 startup_cost += qpqual_cost.
startup;
1612 run_cost += cpu_per_tuple * baserel->
tuples;
1615 startup_cost += path->pathtarget->cost.startup;
1616 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1634 Cost startup_cost = 0;
1658 startup_cost += qpqual_cost.
startup;
1660 run_cost += cpu_per_tuple * baserel->
tuples;
1663 startup_cost += path->pathtarget->cost.startup;
1664 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1685 Cost startup_cost = 0;
1706 startup_cost += qpqual_cost.
startup;
1708 run_cost += cpu_per_tuple * baserel->
tuples;
1711 startup_cost += path->pathtarget->cost.startup;
1712 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1727 Cost startup_cost = 0;
1748 startup_cost += qpqual_cost.
startup;
1750 run_cost += cpu_per_tuple * baserel->
tuples;
1765 Cost startup_cost = 0;
1783 startup_cost += qpqual_cost.
startup;
1785 run_cost += cpu_per_tuple * baserel->
tuples;
1809 total_rows = nrterm->
rows;
1818 total_rows += 10 * rterm->
rows;
1830 runion->
rows = total_rows;
1831 runion->pathtarget->width =
Max(nrterm->pathtarget->width,
1832 rterm->pathtarget->width);
1873 double tuples,
int width,
1874 Cost comparison_cost,
int sort_mem,
1875 double limit_tuples)
1878 double output_bytes;
1879 double output_tuples;
1880 int64 sort_mem_bytes = sort_mem * (
int64) 1024;
1893 if (limit_tuples > 0 && limit_tuples < tuples)
1895 output_tuples = limit_tuples;
1900 output_tuples = tuples;
1901 output_bytes = input_bytes;
1904 if (output_bytes > sort_mem_bytes)
1909 double npages = ceil(input_bytes / BLCKSZ);
1910 double nruns = input_bytes / sort_mem_bytes;
1913 double npageaccesses;
1920 *startup_cost = comparison_cost * tuples *
LOG2(tuples);
1925 if (nruns > mergeorder)
1926 log_runs = ceil(log(nruns) / log(mergeorder));
1929 npageaccesses = 2.0 * npages * log_runs;
1931 *startup_cost += npageaccesses *
1934 else if (tuples > 2 * output_tuples || input_bytes > sort_mem_bytes)
1942 *startup_cost = comparison_cost * tuples *
LOG2(2.0 * output_tuples);
1947 *startup_cost = comparison_cost * tuples *
LOG2(tuples);
1976 int input_disabled_nodes,
1977 Cost input_startup_cost,
Cost input_total_cost,
1978 double input_tuples,
int width,
Cost comparison_cost,
int sort_mem,
1979 double limit_tuples)
1983 input_run_cost = input_total_cost - input_startup_cost;
1984 double group_tuples,
1986 Cost group_startup_cost,
1988 group_input_run_cost;
1991 bool unknown_varno =
false;
1999 if (input_tuples < 2.0)
2027 foreach(l, pathkeys)
2039 unknown_varno =
true;
2055 group_tuples = input_tuples / input_groups;
2056 group_input_run_cost = input_run_cost / input_groups;
2063 group_tuples, width, comparison_cost, sort_mem,
2070 startup_cost = group_startup_cost + input_startup_cost +
2071 group_input_run_cost;
2079 run_cost = group_run_cost + (group_run_cost + group_startup_cost) *
2080 (input_groups - 1) + group_input_run_cost * (input_groups - 1);
2095 path->
rows = input_tuples;
2119 List *pathkeys,
int input_disabled_nodes,
2120 Cost input_cost,
double tuples,
int width,
2121 Cost comparison_cost,
int sort_mem,
2122 double limit_tuples)
2130 comparison_cost, sort_mem,
2133 startup_cost += input_cost;
2135 path->
rows = tuples;
2165 arrlen =
Min(parallel_workers, numpaths);
2170 foreach(cell, subpaths)
2174 if (path_index == arrlen)
2176 costarr[path_index++] =
subpath->total_cost;
2183 min_index = arrlen - 1;
2194 if (path_index++ == numpaths)
2197 costarr[min_index] +=
subpath->total_cost;
2201 for (
int i = 0;
i < arrlen;
i++)
2203 if (costarr[
i] < costarr[min_index])
2210 for (
int i = 0;
i < arrlen;
i++)
2212 if (costarr[
i] > costarr[max_index])
2216 return costarr[max_index];
2240 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)
2550 int width = mpath->
subpath->pathtarget->width;
2552 double hash_mem_bytes;
2553 double est_entry_bytes;
2578 est_cache_entries = floor(hash_mem_bytes / est_entry_bytes);
2593 ndistinct = est_calls;
2616 evict_ratio = 1.0 -
Min(est_cache_entries, ndistinct) / ndistinct;
2624 hit_ratio = ((est_calls - ndistinct) / est_calls) *
2625 (est_cache_entries /
Max(ndistinct, est_cache_entries));
2630 Assert(hit_ratio >= 0 && hit_ratio <= 1.0);
2664 startup_cost = input_startup_cost * (1.0 - hit_ratio);
2672 *rescan_startup_cost = startup_cost;
2673 *rescan_total_cost = total_cost;
2690 int numGroupCols,
double numGroups,
2693 Cost input_startup_cost,
Cost input_total_cost,
2694 double input_tuples,
double input_width)
2696 double output_tuples;
2702 if (aggcosts == NULL)
2705 aggcosts = &dummy_aggcosts;
2732 startup_cost = input_total_cost;
2744 startup_cost = input_startup_cost;
2745 total_cost = input_total_cost;
2755 output_tuples = numGroups;
2760 startup_cost = input_total_cost;
2769 total_cost = startup_cost;
2773 output_tuples = numGroups;
2792 double pages_written = 0.0;
2793 double pages_read = 0.0;
2795 double hashentrysize;
2811 &ngroups_limit, &num_partitions);
2813 nbatches =
Max((numGroups * hashentrysize) / mem_limit,
2814 numGroups / ngroups_limit);
2816 nbatches =
Max(ceil(nbatches), 1.0);
2817 num_partitions =
Max(num_partitions, 2);
2824 depth = ceil(log(nbatches) / log(num_partitions));
2831 pages_written = pages_read = pages * depth;
2838 pages_written *= 2.0;
2846 startup_cost += spill_cost;
2847 total_cost += spill_cost;
2859 startup_cost += qual_cost.
startup;
2870 path->
rows = output_tuples;
2891 double input_tuples)
2894 double partition_tuples;
2895 double return_tuples;
2904 double num_partitions;
2906 root->parse->targetList);
2912 partition_tuples = input_tuples / num_partitions;
2917 partition_tuples = input_tuples;
2927 root->parse->targetList);
2931 partition_tuples, NULL,
2934 peer_tuples = partition_tuples / num_groups;
2945 return_tuples = partition_tuples;
2952 return_tuples = 1.0;
2962 return_tuples = partition_tuples;
2964 return_tuples = peer_tuples;
2973 return_tuples = 1.0;
2984 return_tuples = 1.0;
2989 double end_offset_value;
2994 if (endOffset->constisnull)
3003 end_offset_value = 1.0;
3023 partition_tuples / peer_tuples *
3042 return_tuples = end_offset_value + 1.0;
3047 return_tuples = peer_tuples * (end_offset_value + 1.0);
3056 return_tuples = 1.0;
3066 return_tuples = 1.0;
3076 return_tuples =
Min(return_tuples + 1.0, partition_tuples);
3084 return_tuples =
Min(return_tuples, partition_tuples);
3106 int input_disabled_nodes,
3107 Cost input_startup_cost,
Cost input_total_cost,
3108 double input_tuples)
3112 double startup_tuples;
3120 startup_cost = input_startup_cost;
3121 total_cost = input_total_cost;
3132 foreach(lc, windowFuncs)
3141 startup_cost += argcosts.
startup;
3146 startup_cost += argcosts.
startup;
3154 startup_cost += argcosts.
startup;
3157 total_cost += wfunccost * input_tuples;
3171 path->
rows = input_tuples;
3187 if (startup_tuples > 1.0)
3188 path->
startup_cost += (total_cost - startup_cost) / input_tuples *
3189 (startup_tuples - 1.0);
3202 int numGroupCols,
double numGroups,
3204 int input_disabled_nodes,
3205 Cost input_startup_cost,
Cost input_total_cost,
3206 double input_tuples)
3208 double output_tuples;
3212 output_tuples = numGroups;
3213 startup_cost = input_startup_cost;
3214 total_cost = input_total_cost;
3231 startup_cost += qual_cost.
startup;
3242 path->
rows = output_tuples;
3275 Path *outer_path,
Path *inner_path,
3279 Cost startup_cost = 0;
3281 double outer_path_rows = outer_path->
rows;
3282 Cost inner_rescan_start_cost;
3283 Cost inner_rescan_total_cost;
3284 Cost inner_run_cost;
3285 Cost inner_rescan_run_cost;
3294 &inner_rescan_start_cost,
3295 &inner_rescan_total_cost);
3307 if (outer_path_rows > 1)
3308 run_cost += (outer_path_rows - 1) * inner_rescan_start_cost;
3311 inner_rescan_run_cost = inner_rescan_total_cost - inner_rescan_start_cost;
3331 run_cost += inner_run_cost;
3332 if (outer_path_rows > 1)
3333 run_cost += (outer_path_rows - 1) * inner_rescan_run_cost;
3341 workspace->
total_cost = startup_cost + run_cost;
3361 double outer_path_rows = outer_path->
rows;
3362 double inner_path_rows = inner_path->
rows;
3373 if (outer_path_rows <= 0)
3374 outer_path_rows = 1;
3375 if (inner_path_rows <= 0)
3376 inner_path_rows = 1;
3378 if (path->
jpath.path.param_info)
3379 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3381 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3384 if (path->
jpath.path.parallel_workers > 0)
3388 path->
jpath.path.rows =
3403 double outer_matched_rows;
3404 double outer_unmatched_rows;
3417 outer_unmatched_rows = outer_path_rows - outer_matched_rows;
3424 ntuples = outer_matched_rows * inner_path_rows * inner_scan_frac;
3451 run_cost += inner_run_cost * inner_scan_frac;
3452 if (outer_matched_rows > 1)
3453 run_cost += (outer_matched_rows - 1) * inner_rescan_run_cost * inner_scan_frac;
3461 run_cost += outer_unmatched_rows *
3462 inner_rescan_run_cost / inner_path_rows;
3485 ntuples += outer_unmatched_rows * inner_path_rows;
3488 run_cost += inner_run_cost;
3489 if (outer_unmatched_rows >= 1)
3490 outer_unmatched_rows -= 1;
3492 outer_matched_rows -= 1;
3495 if (outer_matched_rows > 0)
3496 run_cost += outer_matched_rows * inner_rescan_run_cost * inner_scan_frac;
3499 if (outer_unmatched_rows > 0)
3500 run_cost += outer_unmatched_rows * inner_rescan_run_cost;
3508 ntuples = outer_path_rows * inner_path_rows;
3513 startup_cost += restrict_qual_cost.
startup;
3515 run_cost += cpu_per_tuple * ntuples;
3518 startup_cost += path->
jpath.path.pathtarget->cost.startup;
3519 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
3521 path->
jpath.path.startup_cost = startup_cost;
3522 path->
jpath.path.total_cost = startup_cost + run_cost;
3561 Path *outer_path,
Path *inner_path,
3562 List *outersortkeys,
List *innersortkeys,
3563 int outer_presorted_keys,
3567 Cost startup_cost = 0;
3569 double outer_path_rows = outer_path->
rows;
3570 double inner_path_rows = inner_path->
rows;
3571 Cost inner_run_cost;
3584 if (outer_path_rows <= 0)
3585 outer_path_rows = 1;
3586 if (inner_path_rows <= 0)
3587 inner_path_rows = 1;
3600 if (mergeclauses && jointype !=
JOIN_FULL)
3610 opathkeys = outersortkeys ? outersortkeys : outer_path->
pathkeys;
3611 ipathkeys = innersortkeys ? innersortkeys : inner_path->
pathkeys;
3618 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation ||
3621 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
3627 outer_path->parent->relids))
3646 outerstartsel = 0.0;
3652 innerstartsel = 0.0;
3659 outerstartsel = innerstartsel = 0.0;
3660 outerendsel = innerendsel = 1.0;
3667 outer_skip_rows = rint(outer_path_rows * outerstartsel);
3668 inner_skip_rows = rint(inner_path_rows * innerstartsel);
3672 Assert(outer_skip_rows <= outer_rows);
3673 Assert(inner_skip_rows <= inner_rows);
3680 outerstartsel = outer_skip_rows / outer_path_rows;
3681 innerstartsel = inner_skip_rows / inner_path_rows;
3682 outerendsel = outer_rows / outer_path_rows;
3683 innerendsel = inner_rows / inner_path_rows;
3685 Assert(outerstartsel <= outerendsel);
3686 Assert(innerstartsel <= innerendsel);
3710 outer_presorted_keys,
3715 outer_path->pathtarget->width,
3728 outer_path->pathtarget->width,
3739 * (outerendsel - outerstartsel);
3748 * (outerendsel - outerstartsel);
3771 inner_path->pathtarget->width,
3780 * (innerendsel - innerstartsel);
3789 * (innerendsel - innerstartsel);
3805 workspace->
total_cost = startup_cost + run_cost + inner_run_cost;
3849 double inner_path_rows = inner_path->
rows;
3864 double mergejointuples,
3872 if (inner_path_rows <= 0)
3873 inner_path_rows = 1;
3876 if (path->
jpath.path.param_info)
3877 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3879 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3882 if (path->
jpath.path.parallel_workers > 0)
3886 path->
jpath.path.rows =
3949 rescannedtuples = 0;
3952 rescannedtuples = mergejointuples - inner_path_rows;
3954 if (rescannedtuples < 0)
3955 rescannedtuples = 0;
3963 rescanratio = 1.0 + (rescannedtuples / inner_rows);
3974 bare_inner_cost = inner_run_cost * rescanratio;
3989 mat_inner_cost = inner_run_cost +
4021 else if (innersortkeys ==
NIL &&
4038 inner_path->pathtarget->width) >
4046 run_cost += mat_inner_cost;
4048 run_cost += bare_inner_cost;
4057 startup_cost += merge_qual_cost.
startup;
4058 startup_cost += merge_qual_cost.
per_tuple *
4059 (outer_skip_rows + inner_skip_rows * rescanratio);
4061 ((outer_rows - outer_skip_rows) +
4062 (inner_rows - inner_skip_rows) * rescanratio);
4073 startup_cost += qp_qual_cost.
startup;
4075 run_cost += cpu_per_tuple * mergejointuples;
4078 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4079 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4081 path->
jpath.path.startup_cost = startup_cost;
4082 path->
jpath.path.total_cost = startup_cost + run_cost;
4100 foreach(lc, rinfo->scansel_cache)
4104 cache->
collation == pathkey->pk_eclass->ec_collation &&
4126 cache->
collation = pathkey->pk_eclass->ec_collation;
4134 rinfo->scansel_cache =
lappend(rinfo->scansel_cache, cache);
4171 Path *outer_path,
Path *inner_path,
4176 Cost startup_cost = 0;
4178 double outer_path_rows = outer_path->
rows;
4179 double inner_path_rows = inner_path->
rows;
4180 double inner_path_rows_total = inner_path_rows;
4185 size_t space_allowed;
4231 inner_path->pathtarget->width,
4249 double outerpages =
page_size(outer_path_rows,
4250 outer_path->pathtarget->width);
4251 double innerpages =
page_size(inner_path_rows,
4252 inner_path->pathtarget->width);
4263 workspace->
total_cost = startup_cost + run_cost;
4289 double outer_path_rows = outer_path->
rows;
4290 double inner_path_rows = inner_path->
rows;
4300 double hashjointuples;
4301 double virtualbuckets;
4310 if (path->
jpath.path.param_info)
4311 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
4313 path->
jpath.path.rows = path->
jpath.path.parent->rows;
4316 if (path->
jpath.path.parallel_workers > 0)
4320 path->
jpath.path.rows =
4331 virtualbuckets = (double) numbuckets * (
double) numbatches;
4346 innerbucketsize = 1.0 / virtualbuckets;
4353 innerbucketsize = 1.0;
4363 foreach(hcl, otherclauses)
4378 inner_path->parent->relids))
4381 thisbucketsize = restrictinfo->right_bucketsize;
4382 if (thisbucketsize < 0)
4388 &restrictinfo->right_mcvfreq,
4389 &restrictinfo->right_bucketsize);
4390 thisbucketsize = restrictinfo->right_bucketsize;
4392 thismcvfreq = restrictinfo->right_mcvfreq;
4397 inner_path->parent->relids));
4399 thisbucketsize = restrictinfo->left_bucketsize;
4400 if (thisbucketsize < 0)
4406 &restrictinfo->left_mcvfreq,
4407 &restrictinfo->left_bucketsize);
4408 thisbucketsize = restrictinfo->left_bucketsize;
4410 thismcvfreq = restrictinfo->left_mcvfreq;
4413 if (innerbucketsize > thisbucketsize)
4414 innerbucketsize = thisbucketsize;
4415 if (innermcvfreq > thismcvfreq)
4416 innermcvfreq = thismcvfreq;
4447 double outer_matched_rows;
4465 startup_cost += hash_qual_cost.
startup;
4466 run_cost += hash_qual_cost.
per_tuple * outer_matched_rows *
4467 clamp_row_est(inner_path_rows * innerbucketsize * inner_scan_frac) * 0.5;
4483 (outer_path_rows - outer_matched_rows) *
4488 hashjointuples = outer_path_rows - outer_matched_rows;
4490 hashjointuples = outer_matched_rows;
4504 startup_cost += hash_qual_cost.
startup;
4505 run_cost += hash_qual_cost.
per_tuple * outer_path_rows *
4522 startup_cost += qp_qual_cost.
startup;
4524 run_cost += cpu_per_tuple * hashjointuples;
4527 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4528 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4530 path->
jpath.path.startup_cost = startup_cost;
4531 path->
jpath.path.total_cost = startup_cost + run_cost;
4595 Cost plan_run_cost =
plan->total_cost -
plan->startup_cost;
4606 sp_cost.
per_tuple += 0.50 * plan_run_cost;
4651 Cost *rescan_startup_cost,
4652 Cost *rescan_total_cost)
4656 case T_FunctionScan:
4665 *rescan_startup_cost = 0;
4674 if (((
HashPath *) path)->num_batches == 1)
4677 *rescan_startup_cost = 0;
4678 *rescan_total_cost = path->total_cost - path->startup_cost;
4683 *rescan_startup_cost = path->startup_cost;
4684 *rescan_total_cost = path->total_cost;
4688 case T_WorkTableScan:
4698 path->pathtarget->width);
4701 if (nbytes > work_mem_bytes)
4704 double npages = ceil(nbytes / BLCKSZ);
4708 *rescan_startup_cost = 0;
4709 *rescan_total_cost = run_cost;
4725 path->pathtarget->width);
4728 if (nbytes > work_mem_bytes)
4731 double npages = ceil(nbytes / BLCKSZ);
4735 *rescan_startup_cost = 0;
4736 *rescan_total_cost = run_cost;
4742 rescan_startup_cost, rescan_total_cost);
4745 *rescan_startup_cost = path->startup_cost;
4746 *rescan_total_cost = path->total_cost;
4783 *cost = context.
total;
4801 *cost = context.
total;
4820 if (rinfo->eval_cost.startup < 0)
4832 if (rinfo->orclause)
4841 if (rinfo->pseudoconstant)
4847 rinfo->eval_cost = locContext.
total;
4967 &iofunc, &typioparam);
4972 &iofunc, &typisvarlena);
4994 foreach(lc, rcexpr->opnos)
5015 elog(
ERROR,
"cannot handle unplanned sub-select");
5149 foreach(l, restrictlist)
5154 joinquals =
lappend(joinquals, rinfo);
5158 joinquals = restrictlist;
5198 avgmatch = nselec * innerrel->
rows / jselec;
5200 avgmatch =
Max(1.0, avgmatch);
5223 Relids joinrelids = joinpath->path.parent->relids;
5233 if (innerpath->param_info == NULL)
5240 case T_IndexOnlyScan:
5241 indexclauses = ((
IndexPath *) innerpath)->indexclauses;
5243 case T_BitmapHeapScan:
5249 indexclauses = ((
IndexPath *) bmqual)->indexclauses;
5271 foreach(lc, innerpath->param_info->ppi_clauses)
5276 innerpath->parent->relids,
5338 tuples = selec * outer_tuples * inner_tuples;
5389 List *param_clauses)
5409 if (nrows > rel->
rows)
5473 List *restrict_clauses)
5495 if (nrows > rel->
rows)
5558 foreach(l, restrictlist)
5563 pushedquals =
lappend(pushedquals, rinfo);
5565 joinquals =
lappend(joinquals, rinfo);
5609 nrows = outer_rows * inner_rows * fkselec * jselec;
5613 nrows = outer_rows * inner_rows * fkselec * jselec;
5614 if (nrows < outer_rows)
5619 nrows = outer_rows * inner_rows * fkselec * jselec;
5620 if (nrows < outer_rows)
5622 if (nrows < inner_rows)
5627 nrows = outer_rows * fkselec * jselec;
5631 nrows = outer_rows * (1.0 - fkselec * jselec);
5636 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
5664 List **restrictlist)
5668 List *worklist = *restrictlist;
5672 foreach(lc,
root->fkey_list)
5685 ref_is_outer =
false;
5688 ref_is_outer =
true;
5714 if (worklist == *restrictlist)
5718 foreach(cell, worklist)
5721 bool remove_it =
false;
5725 for (
i = 0;
i < fkinfo->
nkeys;
i++)
5727 if (rinfo->parent_ec)
5742 if (fkinfo->
eclass[
i] == rinfo->parent_ec)
5764 removedlist =
lappend(removedlist, rinfo);
5794 if (removedlist ==
NIL ||
5839 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5841 fkselec *= ref_rel->
rows / ref_tuples;
5851 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5853 fkselec *= 1.0 / ref_tuples;
5868 for (
int i = 0;
i < fkinfo->
nkeys;
i++)
5896 *restrictlist = worklist;
5939 int32 item_width = 0;
5970 Var *var = (
Var *) texpr;
6093 if (rte->self_reference)
6137 rel->
tuples = rte->enrtuples;
6222 int64 tuple_width = 0;
6223 bool have_wholerow_var =
false;
6241 ((
Var *) node)->varno == rel->
relid)
6258 have_wholerow_var =
true;
6266 if (rel->attr_widths[ndx] > 0)
6268 tuple_width += rel->attr_widths[ndx];
6278 rel->attr_widths[ndx] = item_width;
6279 tuple_width += item_width;
6290 rel->attr_widths[ndx] = item_width;
6291 tuple_width += item_width;
6320 tuple_width += item_width;
6332 if (have_wholerow_var)
6348 wholerow_width += rel->attr_widths[
i - rel->
min_attr];
6357 tuple_width += wholerow_width;
6378 int64 tuple_width = 0;
6385 foreach(lc, target->
exprs)
6420 const Var *var = (
const Var *) expr;
6427 var->
varno <
root->simple_rel_array_size)
6437 if (rel->attr_widths[ndx] > 0)
6438 return rel->attr_widths[ndx];
6500 double leader_contribution;
6503 if (leader_contribution > 0)
6504 parallel_divisor += leader_contribution;
6507 return parallel_divisor;
6524 Path *bitmapqual,
double loop_count,
6525 Cost *cost_p,
double *tuples_p)
6527 Cost indexTotalCost;
6530 double pages_fetched;
6531 double tuples_fetched;
6546 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
6553 pages_fetched = (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
6563 heap_pages =
Min(pages_fetched, baserel->
pages);
6578 pages_fetched /= loop_count;
6581 if (pages_fetched >=
T)
6584 pages_fetched = ceil(pages_fetched);
6586 if (maxentries < heap_pages)
6598 lossy_pages =
Max(0, heap_pages - maxentries / 2);
6599 exact_pages = heap_pages - lossy_pages;
6608 if (lossy_pages > 0)
6611 (exact_pages / heap_pages) * baserel->
tuples +
6612 (lossy_pages / heap_pages) * baserel->
tuples);
6616 *cost_p = indexTotalCost;
6618 *tuples_p = tuples_fetched;
6620 return pages_fetched;
int compute_parallel_worker(RelOptInfo *rel, double heap_pages, double index_pages, int max_workers)
void(* amcostestimate_function)(PlannerInfo *root, 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)
void cost_append(AppendPath *apath, PlannerInfo *root)
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_ctescan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
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 RELATION_WAS_MADE_UNIQUE(rel, sjinfo, nominal_jointype)
#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
Cardinality est_unique_keys
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)