102 #define LOG2(x) (log(x) / 0.693147180559945)
109 #define APPEND_CPU_COST_MULTIPLIER 0.5
117 #define MAXIMUM_ROWCOUNT 1e100
167 Cost *rescan_startup_cost,
Cost *rescan_total_cost);
187 List **restrictlist);
189 int parallel_workers);
193 static double page_size(
double tuples,
int width);
212 else if (nrows <= 1.0)
246 return (
int32) tuple_width;
272 return (
x < (
double) LONG_MAX) ? (long)
x : LONG_MAX;
287 Cost startup_cost = 0;
290 double spc_seq_page_cost;
315 disk_run_cost = spc_seq_page_cost * baserel->
pages;
320 startup_cost += qpqual_cost.
startup;
322 cpu_run_cost = cpu_per_tuple * baserel->
tuples;
324 startup_cost += path->pathtarget->cost.startup;
325 cpu_run_cost += path->pathtarget->cost.per_tuple * path->
rows;
333 cpu_run_cost /= parallel_divisor;
350 path->
total_cost = startup_cost + cpu_run_cost + disk_run_cost;
364 Cost startup_cost = 0;
369 double spc_seq_page_cost,
370 spc_random_page_cost,
391 &spc_random_page_cost,
396 spc_random_page_cost : spc_seq_page_cost;
402 run_cost += spc_page_cost * baserel->
pages;
414 startup_cost += qpqual_cost.
startup;
416 run_cost += cpu_per_tuple * baserel->
tuples;
418 startup_cost += path->pathtarget->cost.startup;
419 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
440 Cost startup_cost = 0;
476 Cost input_startup_cost,
Cost input_total_cost,
479 Cost startup_cost = 0;
481 Cost comparison_cost;
509 startup_cost += comparison_cost * N * logN;
512 run_cost += path->
path.
rows * comparison_cost * logN;
527 path->
path.
total_cost = (startup_cost + run_cost + input_total_cost);
554 bool indexonly = (path->
path.
pathtype == T_IndexOnlyScan);
557 Cost startup_cost = 0;
559 Cost cpu_run_cost = 0;
560 Cost indexStartupCost;
563 double indexCorrelation,
565 double spc_seq_page_cost,
566 spc_random_page_cost;
571 double tuples_fetched;
572 double pages_fetched;
573 double rand_heap_pages;
589 if (path->
path.param_info)
618 amcostestimate(
root, path, loop_count,
619 &indexStartupCost, &indexTotalCost,
620 &indexSelectivity, &indexCorrelation,
632 startup_cost += indexStartupCost;
633 run_cost += indexTotalCost - indexStartupCost;
640 &spc_random_page_cost,
682 (
double)
index->pages,
686 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
688 rand_heap_pages = pages_fetched;
690 max_IO_cost = (pages_fetched * spc_random_page_cost) / loop_count;
702 pages_fetched = ceil(indexSelectivity * (
double) baserel->
pages);
706 (
double)
index->pages,
710 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
712 min_IO_cost = (pages_fetched * spc_random_page_cost) / loop_count;
722 (
double)
index->pages,
726 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
728 rand_heap_pages = pages_fetched;
731 max_IO_cost = pages_fetched * spc_random_page_cost;
734 pages_fetched = ceil(indexSelectivity * (
double) baserel->
pages);
737 pages_fetched = ceil(pages_fetched * (1.0 - baserel->
allvisfrac));
739 if (pages_fetched > 0)
741 min_IO_cost = spc_random_page_cost;
742 if (pages_fetched > 1)
743 min_IO_cost += (pages_fetched - 1) * spc_seq_page_cost;
757 rand_heap_pages = -1;
785 csquared = indexCorrelation * indexCorrelation;
787 run_cost += max_IO_cost + csquared * (min_IO_cost - max_IO_cost);
797 startup_cost += qpqual_cost.
startup;
800 cpu_run_cost += cpu_per_tuple * tuples_fetched;
803 startup_cost += path->
path.pathtarget->cost.startup;
804 cpu_run_cost += path->
path.pathtarget->cost.per_tuple * path->
path.
rows;
814 cpu_run_cost /= parallel_divisor;
817 run_cost += cpu_run_cost;
845 foreach(lc, qual_clauses)
849 if (rinfo->pseudoconstant)
854 result =
lappend(result, rinfo);
901 double pages_fetched;
907 T = (pages > 1) ? (
double) pages : 1.0;
910 total_pages =
root->total_table_pages + index_pages;
911 total_pages =
Max(total_pages, 1.0);
927 (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
928 if (pages_fetched >=
T)
931 pages_fetched = ceil(pages_fetched);
937 lim = (2.0 *
T *
b) / (2.0 *
T -
b);
938 if (tuples_fetched <= lim)
941 (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
946 b + (tuples_fetched - lim) * (
T -
b) /
T;
948 pages_fetched = ceil(pages_fetched);
950 return pages_fetched;
1015 Path *bitmapqual,
double loop_count)
1017 Cost startup_cost = 0;
1019 Cost indexTotalCost;
1024 double tuples_fetched;
1025 double pages_fetched;
1026 double spc_seq_page_cost,
1027 spc_random_page_cost;
1045 loop_count, &indexTotalCost,
1048 startup_cost += indexTotalCost;
1049 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
1053 &spc_random_page_cost,
1054 &spc_seq_page_cost);
1063 if (pages_fetched >= 2.0)
1064 cost_per_page = spc_random_page_cost -
1065 (spc_random_page_cost - spc_seq_page_cost)
1066 * sqrt(pages_fetched /
T);
1068 cost_per_page = spc_random_page_cost;
1070 run_cost += pages_fetched * cost_per_page;
1083 startup_cost += qpqual_cost.
startup;
1085 cpu_run_cost = cpu_per_tuple * tuples_fetched;
1093 cpu_run_cost /= parallel_divisor;
1099 run_cost += cpu_run_cost;
1102 startup_cost += path->pathtarget->cost.startup;
1103 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1118 *cost = ((
IndexPath *) path)->indextotalcost;
1119 *selec = ((
IndexPath *) path)->indexselectivity;
1184 totalCost += subCost;
1229 totalCost += subCost;
1252 Cost startup_cost = 0;
1259 double spc_random_page_cost;
1273 foreach(l, tidquals)
1306 &spc_random_page_cost,
1310 run_cost += spc_random_page_cost * ntuples;
1319 run_cost += cpu_per_tuple * ntuples;
1322 startup_cost += path->pathtarget->cost.startup;
1323 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1345 Cost startup_cost = 0;
1352 double spc_random_page_cost;
1353 double spc_seq_page_cost;
1368 pages = ceil(selectivity * baserel->
pages);
1381 ntuples = selectivity * baserel->
tuples;
1382 nseqpages = pages - 1.0;
1392 &spc_random_page_cost,
1393 &spc_seq_page_cost);
1396 run_cost += spc_random_page_cost + spc_seq_page_cost * nseqpages;
1411 run_cost += cpu_per_tuple * ntuples;
1414 startup_cost += path->pathtarget->cost.startup;
1415 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1432 bool trivial_pathtarget)
1485 if (qpquals ==
NIL && trivial_pathtarget)
1490 startup_cost = qpqual_cost.
startup;
1495 startup_cost += path->
path.pathtarget->cost.startup;
1496 run_cost += path->
path.pathtarget->cost.per_tuple * path->
path.
rows;
1513 Cost startup_cost = 0;
1551 startup_cost += qpqual_cost.
startup;
1553 run_cost += cpu_per_tuple * baserel->
tuples;
1556 startup_cost += path->pathtarget->cost.startup;
1557 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1574 Cost startup_cost = 0;
1607 startup_cost += qpqual_cost.
startup;
1609 run_cost += cpu_per_tuple * baserel->
tuples;
1612 startup_cost += path->pathtarget->cost.startup;
1613 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1630 Cost startup_cost = 0;
1654 startup_cost += qpqual_cost.
startup;
1656 run_cost += cpu_per_tuple * baserel->
tuples;
1659 startup_cost += path->pathtarget->cost.startup;
1660 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1680 Cost startup_cost = 0;
1701 startup_cost += qpqual_cost.
startup;
1703 run_cost += cpu_per_tuple * baserel->
tuples;
1706 startup_cost += path->pathtarget->cost.startup;
1707 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1721 Cost startup_cost = 0;
1742 startup_cost += qpqual_cost.
startup;
1744 run_cost += cpu_per_tuple * baserel->
tuples;
1758 Cost startup_cost = 0;
1776 startup_cost += qpqual_cost.
startup;
1778 run_cost += cpu_per_tuple * baserel->
tuples;
1801 total_rows = nrterm->
rows;
1810 total_rows += 10 * rterm->
rows;
1821 runion->
rows = total_rows;
1822 runion->pathtarget->width =
Max(nrterm->pathtarget->width,
1823 rterm->pathtarget->width);
1864 double tuples,
int width,
1865 Cost comparison_cost,
int sort_mem,
1866 double limit_tuples)
1869 double output_bytes;
1870 double output_tuples;
1871 long sort_mem_bytes = sort_mem * 1024L;
1884 if (limit_tuples > 0 && limit_tuples < tuples)
1886 output_tuples = limit_tuples;
1891 output_tuples = tuples;
1892 output_bytes = input_bytes;
1895 if (output_bytes > sort_mem_bytes)
1900 double npages = ceil(input_bytes / BLCKSZ);
1901 double nruns = input_bytes / sort_mem_bytes;
1904 double npageaccesses;
1911 *startup_cost = comparison_cost * tuples *
LOG2(tuples);
1916 if (nruns > mergeorder)
1917 log_runs = ceil(log(nruns) / log(mergeorder));
1920 npageaccesses = 2.0 * npages * log_runs;
1922 *startup_cost += npageaccesses *
1925 else if (tuples > 2 * output_tuples || input_bytes > sort_mem_bytes)
1933 *startup_cost = comparison_cost * tuples *
LOG2(2.0 * output_tuples);
1938 *startup_cost = comparison_cost * tuples *
LOG2(tuples);
1967 Cost input_startup_cost,
Cost input_total_cost,
1968 double input_tuples,
int width,
Cost comparison_cost,
int sort_mem,
1969 double limit_tuples)
1973 input_run_cost = input_total_cost - input_startup_cost;
1974 double group_tuples,
1976 Cost group_startup_cost,
1978 group_input_run_cost;
1981 bool unknown_varno =
false;
1989 if (input_tuples < 2.0)
2017 foreach(l, pathkeys)
2029 unknown_varno =
true;
2045 group_tuples = input_tuples / input_groups;
2046 group_input_run_cost = input_run_cost / input_groups;
2053 group_tuples, width, comparison_cost, sort_mem,
2060 startup_cost = group_startup_cost + input_startup_cost +
2061 group_input_run_cost;
2069 run_cost = group_run_cost + (group_run_cost + group_startup_cost) *
2070 (input_groups - 1) + group_input_run_cost * (input_groups - 1);
2085 path->
rows = input_tuples;
2104 List *pathkeys,
Cost input_cost,
double tuples,
int width,
2105 Cost comparison_cost,
int sort_mem,
2106 double limit_tuples)
2114 comparison_cost, sort_mem,
2120 startup_cost += input_cost;
2122 path->
rows = tuples;
2151 arrlen =
Min(parallel_workers, numpaths);
2156 foreach(cell, subpaths)
2160 if (path_index == arrlen)
2162 costarr[path_index++] =
subpath->total_cost;
2169 min_index = arrlen - 1;
2180 if (path_index++ == numpaths)
2183 costarr[min_index] +=
subpath->total_cost;
2187 for (
int i = 0;
i < arrlen;
i++)
2189 if (costarr[
i] < costarr[min_index])
2196 for (
int i = 0;
i < arrlen;
i++)
2198 if (costarr[
i] > costarr[max_index])
2202 return costarr[max_index];
2225 if (pathkeys ==
NIL)
2315 else if (i < apath->path.parallel_workers)
2326 if (i < apath->first_partial_path)
2330 double subpath_parallel_divisor;
2384 List *pathkeys,
int n_streams,
2385 Cost input_startup_cost,
Cost input_total_cost,
2388 Cost startup_cost = 0;
2390 Cost comparison_cost;
2397 N = (n_streams < 2) ? 2.0 : (
double) n_streams;
2404 startup_cost += comparison_cost * N * logN;
2407 run_cost += tuples * comparison_cost * logN;
2415 path->
startup_cost = startup_cost + input_startup_cost;
2416 path->
total_cost = startup_cost + run_cost + input_total_cost;
2433 Cost input_startup_cost,
Cost input_total_cost,
2434 double tuples,
int width)
2436 Cost startup_cost = input_startup_cost;
2437 Cost run_cost = input_total_cost - input_startup_cost;
2439 long work_mem_bytes =
work_mem * 1024L;
2441 path->
rows = tuples;
2463 if (nbytes > work_mem_bytes)
2465 double npages = ceil(nbytes / BLCKSZ);
2489 Cost *rescan_startup_cost,
Cost *rescan_total_cost)
2496 double calls = mpath->
calls;
2497 int width = mpath->
subpath->pathtarget->width;
2499 double hash_mem_bytes;
2500 double est_entry_bytes;
2501 double est_cache_entries;
2525 est_cache_entries = floor(hash_mem_bytes / est_entry_bytes);
2560 evict_ratio = 1.0 -
Min(est_cache_entries, ndistinct) / ndistinct;
2568 hit_ratio = ((calls - ndistinct) / calls) *
2569 (est_cache_entries /
Max(ndistinct, est_cache_entries));
2571 Assert(hit_ratio >= 0 && hit_ratio <= 1.0);
2605 startup_cost = input_startup_cost * (1.0 - hit_ratio);
2613 *rescan_startup_cost = startup_cost;
2614 *rescan_total_cost = total_cost;
2631 int numGroupCols,
double numGroups,
2633 Cost input_startup_cost,
Cost input_total_cost,
2634 double input_tuples,
double input_width)
2636 double output_tuples;
2642 if (aggcosts == NULL)
2646 aggcosts = &dummy_aggcosts;
2673 startup_cost = input_total_cost;
2685 startup_cost = input_startup_cost;
2686 total_cost = input_total_cost;
2699 output_tuples = numGroups;
2704 startup_cost = input_total_cost;
2713 total_cost = startup_cost;
2717 output_tuples = numGroups;
2736 double pages_written = 0.0;
2737 double pages_read = 0.0;
2739 double hashentrysize;
2742 uint64 ngroups_limit;
2755 &ngroups_limit, &num_partitions);
2757 nbatches =
Max((numGroups * hashentrysize) / mem_limit,
2758 numGroups / ngroups_limit);
2760 nbatches =
Max(ceil(nbatches), 1.0);
2761 num_partitions =
Max(num_partitions, 2);
2768 depth = ceil(log(nbatches) / log(num_partitions));
2775 pages_written = pages_read = pages * depth;
2782 pages_written *= 2.0;
2790 startup_cost += spill_cost;
2791 total_cost += spill_cost;
2803 startup_cost += qual_cost.
startup;
2814 path->
rows = output_tuples;
2834 double input_tuples)
2837 double partition_tuples;
2838 double return_tuples;
2847 double num_partitions;
2849 root->parse->targetList);
2855 partition_tuples = input_tuples / num_partitions;
2860 partition_tuples = input_tuples;
2870 root->parse->targetList);
2874 partition_tuples, NULL,
2877 peer_tuples = partition_tuples / num_groups;
2888 return_tuples = partition_tuples;
2895 return_tuples = 1.0;
2905 return_tuples = partition_tuples;
2907 return_tuples = peer_tuples;
2916 return_tuples = 1.0;
2927 return_tuples = 1.0;
2932 double end_offset_value;
2937 if (endOffset->constisnull)
2946 end_offset_value = 1.0;
2966 partition_tuples / peer_tuples *
2985 return_tuples = end_offset_value + 1.0;
2990 return_tuples = peer_tuples * (end_offset_value + 1.0);
2999 return_tuples = 1.0;
3009 return_tuples = 1.0;
3019 return_tuples =
Min(return_tuples + 1.0, partition_tuples);
3027 return_tuples =
Min(return_tuples, partition_tuples);
3049 Cost input_startup_cost,
Cost input_total_cost,
3050 double input_tuples)
3054 double startup_tuples;
3062 startup_cost = input_startup_cost;
3063 total_cost = input_total_cost;
3074 foreach(lc, windowFuncs)
3083 startup_cost += argcosts.
startup;
3088 startup_cost += argcosts.
startup;
3096 startup_cost += argcosts.
startup;
3099 total_cost += wfunccost * input_tuples;
3113 path->
rows = input_tuples;
3128 if (startup_tuples > 1.0)
3129 path->
startup_cost += (total_cost - startup_cost) / input_tuples *
3130 (startup_tuples - 1.0);
3143 int numGroupCols,
double numGroups,
3145 Cost input_startup_cost,
Cost input_total_cost,
3146 double input_tuples)
3148 double output_tuples;
3152 output_tuples = numGroups;
3153 startup_cost = input_startup_cost;
3154 total_cost = input_total_cost;
3171 startup_cost += qual_cost.
startup;
3182 path->
rows = output_tuples;
3214 Path *outer_path,
Path *inner_path,
3217 Cost startup_cost = 0;
3219 double outer_path_rows = outer_path->
rows;
3220 Cost inner_rescan_start_cost;
3221 Cost inner_rescan_total_cost;
3222 Cost inner_run_cost;
3223 Cost inner_rescan_run_cost;
3227 &inner_rescan_start_cost,
3228 &inner_rescan_total_cost);
3240 if (outer_path_rows > 1)
3241 run_cost += (outer_path_rows - 1) * inner_rescan_start_cost;
3244 inner_rescan_run_cost = inner_rescan_total_cost - inner_rescan_start_cost;
3264 run_cost += inner_run_cost;
3265 if (outer_path_rows > 1)
3266 run_cost += (outer_path_rows - 1) * inner_rescan_run_cost;
3273 workspace->
total_cost = startup_cost + run_cost;
3293 double outer_path_rows = outer_path->
rows;
3294 double inner_path_rows = inner_path->
rows;
3302 if (outer_path_rows <= 0)
3303 outer_path_rows = 1;
3304 if (inner_path_rows <= 0)
3305 inner_path_rows = 1;
3307 if (path->
jpath.path.param_info)
3308 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3310 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3313 if (path->
jpath.path.parallel_workers > 0)
3317 path->
jpath.path.rows =
3340 double outer_matched_rows;
3341 double outer_unmatched_rows;
3354 outer_unmatched_rows = outer_path_rows - outer_matched_rows;
3361 ntuples = outer_matched_rows * inner_path_rows * inner_scan_frac;
3388 run_cost += inner_run_cost * inner_scan_frac;
3389 if (outer_matched_rows > 1)
3390 run_cost += (outer_matched_rows - 1) * inner_rescan_run_cost * inner_scan_frac;
3398 run_cost += outer_unmatched_rows *
3399 inner_rescan_run_cost / inner_path_rows;
3422 ntuples += outer_unmatched_rows * inner_path_rows;
3425 run_cost += inner_run_cost;
3426 if (outer_unmatched_rows >= 1)
3427 outer_unmatched_rows -= 1;
3429 outer_matched_rows -= 1;
3432 if (outer_matched_rows > 0)
3433 run_cost += outer_matched_rows * inner_rescan_run_cost * inner_scan_frac;
3436 if (outer_unmatched_rows > 0)
3437 run_cost += outer_unmatched_rows * inner_rescan_run_cost;
3445 ntuples = outer_path_rows * inner_path_rows;
3450 startup_cost += restrict_qual_cost.
startup;
3452 run_cost += cpu_per_tuple * ntuples;
3455 startup_cost += path->
jpath.path.pathtarget->cost.startup;
3456 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
3458 path->
jpath.path.startup_cost = startup_cost;
3459 path->
jpath.path.total_cost = startup_cost + run_cost;
3496 Path *outer_path,
Path *inner_path,
3497 List *outersortkeys,
List *innersortkeys,
3500 Cost startup_cost = 0;
3502 double outer_path_rows = outer_path->
rows;
3503 double inner_path_rows = inner_path->
rows;
3504 Cost inner_run_cost;
3516 if (outer_path_rows <= 0)
3517 outer_path_rows = 1;
3518 if (inner_path_rows <= 0)
3519 inner_path_rows = 1;
3532 if (mergeclauses && jointype !=
JOIN_FULL)
3542 opathkeys = outersortkeys ? outersortkeys : outer_path->
pathkeys;
3543 ipathkeys = innersortkeys ? innersortkeys : inner_path->
pathkeys;
3550 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation ||
3553 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
3559 outer_path->parent->relids))
3578 outerstartsel = 0.0;
3584 innerstartsel = 0.0;
3591 outerstartsel = innerstartsel = 0.0;
3592 outerendsel = innerendsel = 1.0;
3599 outer_skip_rows = rint(outer_path_rows * outerstartsel);
3600 inner_skip_rows = rint(inner_path_rows * innerstartsel);
3604 Assert(outer_skip_rows <= outer_rows);
3605 Assert(inner_skip_rows <= inner_rows);
3612 outerstartsel = outer_skip_rows / outer_path_rows;
3613 innerstartsel = inner_skip_rows / inner_path_rows;
3614 outerendsel = outer_rows / outer_path_rows;
3615 innerendsel = inner_rows / inner_path_rows;
3617 Assert(outerstartsel <= outerendsel);
3618 Assert(innerstartsel <= innerendsel);
3629 outer_path->pathtarget->width,
3637 * (outerendsel - outerstartsel);
3645 * (outerendsel - outerstartsel);
3655 inner_path->pathtarget->width,
3663 * (innerendsel - innerstartsel);
3671 * (innerendsel - innerstartsel);
3686 workspace->
total_cost = startup_cost + run_cost + inner_run_cost;
3730 double inner_path_rows = inner_path->
rows;
3745 double mergejointuples,
3750 if (inner_path_rows <= 0)
3751 inner_path_rows = 1;
3754 if (path->
jpath.path.param_info)
3755 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3757 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3760 if (path->
jpath.path.parallel_workers > 0)
3764 path->
jpath.path.rows =
3833 rescannedtuples = 0;
3836 rescannedtuples = mergejointuples - inner_path_rows;
3838 if (rescannedtuples < 0)
3839 rescannedtuples = 0;
3847 rescanratio = 1.0 + (rescannedtuples / inner_rows);
3858 bare_inner_cost = inner_run_cost * rescanratio;
3873 mat_inner_cost = inner_run_cost +
3905 else if (innersortkeys ==
NIL &&
3922 inner_path->pathtarget->width) >
3930 run_cost += mat_inner_cost;
3932 run_cost += bare_inner_cost;
3941 startup_cost += merge_qual_cost.
startup;
3942 startup_cost += merge_qual_cost.
per_tuple *
3943 (outer_skip_rows + inner_skip_rows * rescanratio);
3945 ((outer_rows - outer_skip_rows) +
3946 (inner_rows - inner_skip_rows) * rescanratio);
3957 startup_cost += qp_qual_cost.
startup;
3959 run_cost += cpu_per_tuple * mergejointuples;
3962 startup_cost += path->
jpath.path.pathtarget->cost.startup;
3963 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
3965 path->
jpath.path.startup_cost = startup_cost;
3966 path->
jpath.path.total_cost = startup_cost + run_cost;
3984 foreach(lc, rinfo->scansel_cache)
3988 cache->
collation == pathkey->pk_eclass->ec_collation &&
4010 cache->
collation = pathkey->pk_eclass->ec_collation;
4018 rinfo->scansel_cache =
lappend(rinfo->scansel_cache, cache);
4055 Path *outer_path,
Path *inner_path,
4059 Cost startup_cost = 0;
4061 double outer_path_rows = outer_path->
rows;
4062 double inner_path_rows = inner_path->
rows;
4063 double inner_path_rows_total = inner_path_rows;
4068 size_t space_allowed;
4109 inner_path->pathtarget->width,
4127 double outerpages =
page_size(outer_path_rows,
4128 outer_path->pathtarget->width);
4129 double innerpages =
page_size(inner_path_rows,
4130 inner_path->pathtarget->width);
4140 workspace->
total_cost = startup_cost + run_cost;
4166 double outer_path_rows = outer_path->
rows;
4167 double inner_path_rows = inner_path->
rows;
4177 double hashjointuples;
4178 double virtualbuckets;
4184 if (path->
jpath.path.param_info)
4185 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
4187 path->
jpath.path.rows = path->
jpath.path.parent->rows;
4190 if (path->
jpath.path.parallel_workers > 0)
4194 path->
jpath.path.rows =
4213 virtualbuckets = (double) numbuckets * (
double) numbatches;
4227 innerbucketsize = 1.0 / virtualbuckets;
4232 innerbucketsize = 1.0;
4234 foreach(hcl, hashclauses)
4249 inner_path->parent->relids))
4252 thisbucketsize = restrictinfo->right_bucketsize;
4253 if (thisbucketsize < 0)
4259 &restrictinfo->right_mcvfreq,
4260 &restrictinfo->right_bucketsize);
4261 thisbucketsize = restrictinfo->right_bucketsize;
4263 thismcvfreq = restrictinfo->right_mcvfreq;
4268 inner_path->parent->relids));
4270 thisbucketsize = restrictinfo->left_bucketsize;
4271 if (thisbucketsize < 0)
4277 &restrictinfo->left_mcvfreq,
4278 &restrictinfo->left_bucketsize);
4279 thisbucketsize = restrictinfo->left_bucketsize;
4281 thismcvfreq = restrictinfo->left_mcvfreq;
4284 if (innerbucketsize > thisbucketsize)
4285 innerbucketsize = thisbucketsize;
4286 if (innermcvfreq > thismcvfreq)
4287 innermcvfreq = thismcvfreq;
4318 double outer_matched_rows;
4336 startup_cost += hash_qual_cost.
startup;
4337 run_cost += hash_qual_cost.
per_tuple * outer_matched_rows *
4338 clamp_row_est(inner_path_rows * innerbucketsize * inner_scan_frac) * 0.5;
4354 (outer_path_rows - outer_matched_rows) *
4359 hashjointuples = outer_path_rows - outer_matched_rows;
4361 hashjointuples = outer_matched_rows;
4375 startup_cost += hash_qual_cost.
startup;
4376 run_cost += hash_qual_cost.
per_tuple * outer_path_rows *
4393 startup_cost += qp_qual_cost.
startup;
4395 run_cost += cpu_per_tuple * hashjointuples;
4398 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4399 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4401 path->
jpath.path.startup_cost = startup_cost;
4402 path->
jpath.path.total_cost = startup_cost + run_cost;
4452 Cost plan_run_cost =
plan->total_cost -
plan->startup_cost;
4463 sp_cost.
per_tuple += 0.50 * plan_run_cost;
4508 Cost *rescan_startup_cost,
4509 Cost *rescan_total_cost)
4513 case T_FunctionScan:
4522 *rescan_startup_cost = 0;
4531 if (((
HashPath *) path)->num_batches == 1)
4534 *rescan_startup_cost = 0;
4535 *rescan_total_cost = path->total_cost - path->startup_cost;
4540 *rescan_startup_cost = path->startup_cost;
4541 *rescan_total_cost = path->total_cost;
4545 case T_WorkTableScan:
4555 path->pathtarget->width);
4556 long work_mem_bytes =
work_mem * 1024L;
4558 if (nbytes > work_mem_bytes)
4561 double npages = ceil(nbytes / BLCKSZ);
4565 *rescan_startup_cost = 0;
4566 *rescan_total_cost = run_cost;
4582 path->pathtarget->width);
4583 long work_mem_bytes =
work_mem * 1024L;
4585 if (nbytes > work_mem_bytes)
4588 double npages = ceil(nbytes / BLCKSZ);
4592 *rescan_startup_cost = 0;
4593 *rescan_total_cost = run_cost;
4599 rescan_startup_cost, rescan_total_cost);
4602 *rescan_startup_cost = path->startup_cost;
4603 *rescan_total_cost = path->total_cost;
4674 if (rinfo->eval_cost.startup < 0)
4686 if (rinfo->orclause)
4695 if (rinfo->pseudoconstant)
4701 rinfo->eval_cost = locContext.
total;
4703 context->total.startup += rinfo->eval_cost.startup;
4704 context->total.per_tuple += rinfo->eval_cost.per_tuple;
4821 &iofunc, &typioparam);
4826 &iofunc, &typisvarlena);
4848 foreach(lc, rcexpr->opnos)
4869 elog(
ERROR,
"cannot handle unplanned sub-select");
5004 foreach(l, restrictlist)
5009 joinquals =
lappend(joinquals, rinfo);
5013 joinquals = restrictlist;
5053 avgmatch = nselec * innerrel->
rows / jselec;
5055 avgmatch =
Max(1.0, avgmatch);
5078 Relids joinrelids = joinpath->path.parent->relids;
5088 if (innerpath->param_info == NULL)
5095 case T_IndexOnlyScan:
5096 indexclauses = ((
IndexPath *) innerpath)->indexclauses;
5098 case T_BitmapHeapScan:
5104 indexclauses = ((
IndexPath *) bmqual)->indexclauses;
5126 foreach(lc, innerpath->param_info->ppi_clauses)
5131 innerpath->parent->relids,
5193 tuples = selec * outer_tuples * inner_tuples;
5244 List *param_clauses)
5264 if (nrows > rel->
rows)
5328 List *restrict_clauses)
5350 if (nrows > rel->
rows)
5413 foreach(l, restrictlist)
5418 pushedquals =
lappend(pushedquals, rinfo);
5420 joinquals =
lappend(joinquals, rinfo);
5464 nrows = outer_rows * inner_rows * fkselec * jselec;
5468 nrows = outer_rows * inner_rows * fkselec * jselec;
5469 if (nrows < outer_rows)
5474 nrows = outer_rows * inner_rows * fkselec * jselec;
5475 if (nrows < outer_rows)
5477 if (nrows < inner_rows)
5482 nrows = outer_rows * fkselec * jselec;
5486 nrows = outer_rows * (1.0 - fkselec * jselec);
5491 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
5519 List **restrictlist)
5523 List *worklist = *restrictlist;
5527 foreach(lc,
root->fkey_list)
5540 ref_is_outer =
false;
5543 ref_is_outer =
true;
5569 if (worklist == *restrictlist)
5573 foreach(cell, worklist)
5576 bool remove_it =
false;
5580 for (
i = 0;
i < fkinfo->
nkeys;
i++)
5582 if (rinfo->parent_ec)
5597 if (fkinfo->
eclass[
i] == rinfo->parent_ec)
5619 removedlist =
lappend(removedlist, rinfo);
5649 if (removedlist ==
NIL ||
5694 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5696 fkselec *= ref_rel->
rows / ref_tuples;
5706 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5708 fkselec *= 1.0 / ref_tuples;
5723 for (
int i = 0;
i < fkinfo->
nkeys;
i++)
5750 *restrictlist = worklist;
5793 int32 item_width = 0;
5824 Var *var = (
Var *) texpr;
5947 if (rte->self_reference)
5991 rel->
tuples = rte->enrtuples;
6076 int64 tuple_width = 0;
6077 bool have_wholerow_var =
false;
6095 ((
Var *) node)->varno == rel->
relid)
6112 have_wholerow_var =
true;
6120 if (rel->attr_widths[ndx] > 0)
6122 tuple_width += rel->attr_widths[ndx];
6132 rel->attr_widths[ndx] = item_width;
6133 tuple_width += item_width;
6144 rel->attr_widths[ndx] = item_width;
6145 tuple_width += item_width;
6174 tuple_width += item_width;
6186 if (have_wholerow_var)
6202 wholerow_width += rel->attr_widths[
i - rel->
min_attr];
6211 tuple_width += wholerow_width;
6232 int64 tuple_width = 0;
6239 foreach(lc, target->
exprs)
6274 const Var *var = (
const Var *) expr;
6281 var->
varno <
root->simple_rel_array_size)
6291 if (rel->attr_widths[ndx] > 0)
6292 return rel->attr_widths[ndx];
6354 double leader_contribution;
6357 if (leader_contribution > 0)
6358 parallel_divisor += leader_contribution;
6361 return parallel_divisor;
6378 Path *bitmapqual,
double loop_count,
6379 Cost *cost_p,
double *tuples_p)
6381 Cost indexTotalCost;
6384 double pages_fetched;
6385 double tuples_fetched;
6400 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
6407 pages_fetched = (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
6417 heap_pages =
Min(pages_fetched, baserel->
pages);
6432 pages_fetched /= loop_count;
6435 if (pages_fetched >=
T)
6438 pages_fetched = ceil(pages_fetched);
6440 if (maxentries < heap_pages)
6452 lossy_pages =
Max(0, heap_pages - maxentries / 2);
6453 exact_pages = heap_pages - lossy_pages;
6462 if (lossy_pages > 0)
6465 (exact_pages / heap_pages) * baserel->
tuples +
6466 (lossy_pages / heap_pages) * baserel->
tuples);
6470 *cost_p = indexTotalCost;
6472 *tuples_p = tuples_fetched;
6474 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 Assert(condition)
#define MemSet(start, val, len)
#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)
double recursive_worktable_factor
void cost_functionscan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
void cost_material(Path *path, 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)
PathTarget * set_pathtarget_cost_width(PlannerInfo *root, PathTarget *target)
double parallel_tuple_cost
void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void cost_merge_append(Path *path, PlannerInfo *root, List *pathkeys, int n_streams, Cost input_startup_cost, Cost input_total_cost, double 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_recursive_union(Path *runion, Path *nrterm, Path *rterm)
void cost_incremental_sort(Path *path, PlannerInfo *root, List *pathkeys, int presorted_keys, Cost input_startup_cost, Cost input_total_cost, double input_tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
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_agg(Path *path, PlannerInfo *root, AggStrategy aggstrategy, const AggClauseCosts *aggcosts, int numGroupCols, double numGroups, List *quals, Cost input_startup_cost, Cost input_total_cost, double input_tuples, double input_width)
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)
void cost_valuesscan(Path *path, PlannerInfo *root, RelOptInfo *baserel, ParamPathInfo *param_info)
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_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_windowagg(Path *path, PlannerInfo *root, List *windowFuncs, WindowClause *winclause, Cost input_startup_cost, Cost input_total_cost, double input_tuples)
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_gather_merge(GatherMergePath *path, PlannerInfo *root, RelOptInfo *rel, ParamPathInfo *param_info, Cost input_startup_cost, Cost input_total_cost, double *rows)
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)
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 cost_sort(Path *path, PlannerInfo *root, List *pathkeys, Cost input_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
void cost_group(Path *path, PlannerInfo *root, int numGroupCols, double numGroups, List *quals, Cost input_startup_cost, Cost input_total_cost, double input_tuples)
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(EquivalenceClass *ec, EquivalenceMember *em)
bool ExecSupportsMarkRestore(Path *pathnode)
bool ExecMaterializesOutput(NodeTag plantype)
#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_copy(const List *oldlist)
bool list_member_ptr(const List *list, const void *datum)
void list_free(List *list)
List * list_concat(List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
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)
#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)
MemoryContextSwitchTo(old_ctx)
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)
double estimate_array_length(PlannerInfo *root, Node *arrayexpr)
void mergejoinscansel(PlannerInfo *root, Node *clause, Oid opfamily, int strategy, bool nulls_first, Selectivity *leftstart, Selectivity *leftend, Selectivity *rightstart, Selectivity *rightend)
double estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows, List **pgset, EstimationInfo *estinfo)
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)
long tbm_calculate_entries(double maxbytes)
List * get_sortgrouplist_exprs(List *sgClauses, List *targetList)
int tuplesort_merge_order(int64 allowedMem)
Relids pull_varnos(PlannerInfo *root, Node *node)