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)
2388 else if (i < apath->path.parallel_workers)
2399 if (i < apath->first_partial_path)
2403 double subpath_parallel_divisor;
2459 List *pathkeys,
int n_streams,
2460 int input_disabled_nodes,
2461 Cost input_startup_cost,
Cost input_total_cost,
2464 Cost startup_cost = 0;
2466 Cost comparison_cost;
2473 N = (n_streams < 2) ? 2.0 : (
double) n_streams;
2480 startup_cost += comparison_cost * N * logN;
2483 run_cost += tuples * comparison_cost * logN;
2492 path->
startup_cost = startup_cost + input_startup_cost;
2493 path->
total_cost = startup_cost + run_cost + input_total_cost;
2510 int input_disabled_nodes,
2511 Cost input_startup_cost,
Cost input_total_cost,
2512 double tuples,
int width)
2514 Cost startup_cost = input_startup_cost;
2515 Cost run_cost = input_total_cost - input_startup_cost;
2519 path->
rows = tuples;
2541 if (nbytes > work_mem_bytes)
2543 double npages = ceil(nbytes / BLCKSZ);
2568 Cost *rescan_startup_cost,
Cost *rescan_total_cost)
2576 int width = mpath->
subpath->pathtarget->width;
2578 double hash_mem_bytes;
2579 double est_entry_bytes;
2604 est_cache_entries = floor(hash_mem_bytes / est_entry_bytes);
2619 ndistinct = est_calls;
2642 evict_ratio = 1.0 -
Min(est_cache_entries, ndistinct) / ndistinct;
2650 hit_ratio = ((est_calls - ndistinct) / est_calls) *
2651 (est_cache_entries /
Max(ndistinct, est_cache_entries));
2656 Assert(hit_ratio >= 0 && hit_ratio <= 1.0);
2690 startup_cost = input_startup_cost * (1.0 - hit_ratio);
2698 *rescan_startup_cost = startup_cost;
2699 *rescan_total_cost = total_cost;
2716 int numGroupCols,
double numGroups,
2719 Cost input_startup_cost,
Cost input_total_cost,
2720 double input_tuples,
double input_width)
2722 double output_tuples;
2728 if (aggcosts == NULL)
2731 aggcosts = &dummy_aggcosts;
2758 startup_cost = input_total_cost;
2770 startup_cost = input_startup_cost;
2771 total_cost = input_total_cost;
2781 output_tuples = numGroups;
2786 startup_cost = input_total_cost;
2795 total_cost = startup_cost;
2799 output_tuples = numGroups;
2818 double pages_written = 0.0;
2819 double pages_read = 0.0;
2821 double hashentrysize;
2837 &ngroups_limit, &num_partitions);
2839 nbatches =
Max((numGroups * hashentrysize) / mem_limit,
2840 numGroups / ngroups_limit);
2842 nbatches =
Max(ceil(nbatches), 1.0);
2843 num_partitions =
Max(num_partitions, 2);
2850 depth = ceil(log(nbatches) / log(num_partitions));
2857 pages_written = pages_read = pages * depth;
2864 pages_written *= 2.0;
2872 startup_cost += spill_cost;
2873 total_cost += spill_cost;
2885 startup_cost += qual_cost.
startup;
2896 path->
rows = output_tuples;
2917 double input_tuples)
2920 double partition_tuples;
2921 double return_tuples;
2930 double num_partitions;
2932 root->parse->targetList);
2938 partition_tuples = input_tuples / num_partitions;
2943 partition_tuples = input_tuples;
2953 root->parse->targetList);
2957 partition_tuples, NULL,
2960 peer_tuples = partition_tuples / num_groups;
2971 return_tuples = partition_tuples;
2978 return_tuples = 1.0;
2988 return_tuples = partition_tuples;
2990 return_tuples = peer_tuples;
2999 return_tuples = 1.0;
3010 return_tuples = 1.0;
3015 double end_offset_value;
3020 if (endOffset->constisnull)
3029 end_offset_value = 1.0;
3049 partition_tuples / peer_tuples *
3068 return_tuples = end_offset_value + 1.0;
3073 return_tuples = peer_tuples * (end_offset_value + 1.0);
3082 return_tuples = 1.0;
3092 return_tuples = 1.0;
3102 return_tuples =
Min(return_tuples + 1.0, partition_tuples);
3110 return_tuples =
Min(return_tuples, partition_tuples);
3132 int input_disabled_nodes,
3133 Cost input_startup_cost,
Cost input_total_cost,
3134 double input_tuples)
3138 double startup_tuples;
3146 startup_cost = input_startup_cost;
3147 total_cost = input_total_cost;
3158 foreach(lc, windowFuncs)
3167 startup_cost += argcosts.
startup;
3172 startup_cost += argcosts.
startup;
3180 startup_cost += argcosts.
startup;
3183 total_cost += wfunccost * input_tuples;
3197 path->
rows = input_tuples;
3213 if (startup_tuples > 1.0)
3214 path->
startup_cost += (total_cost - startup_cost) / input_tuples *
3215 (startup_tuples - 1.0);
3228 int numGroupCols,
double numGroups,
3230 int input_disabled_nodes,
3231 Cost input_startup_cost,
Cost input_total_cost,
3232 double input_tuples)
3234 double output_tuples;
3238 output_tuples = numGroups;
3239 startup_cost = input_startup_cost;
3240 total_cost = input_total_cost;
3257 startup_cost += qual_cost.
startup;
3268 path->
rows = output_tuples;
3301 Path *outer_path,
Path *inner_path,
3305 Cost startup_cost = 0;
3307 double outer_path_rows = outer_path->
rows;
3308 Cost inner_rescan_start_cost;
3309 Cost inner_rescan_total_cost;
3310 Cost inner_run_cost;
3311 Cost inner_rescan_run_cost;
3320 &inner_rescan_start_cost,
3321 &inner_rescan_total_cost);
3333 if (outer_path_rows > 1)
3334 run_cost += (outer_path_rows - 1) * inner_rescan_start_cost;
3337 inner_rescan_run_cost = inner_rescan_total_cost - inner_rescan_start_cost;
3357 run_cost += inner_run_cost;
3358 if (outer_path_rows > 1)
3359 run_cost += (outer_path_rows - 1) * inner_rescan_run_cost;
3367 workspace->
total_cost = startup_cost + run_cost;
3387 double outer_path_rows = outer_path->
rows;
3388 double inner_path_rows = inner_path->
rows;
3399 if (outer_path_rows <= 0)
3400 outer_path_rows = 1;
3401 if (inner_path_rows <= 0)
3402 inner_path_rows = 1;
3404 if (path->
jpath.path.param_info)
3405 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3407 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3410 if (path->
jpath.path.parallel_workers > 0)
3414 path->
jpath.path.rows =
3429 double outer_matched_rows;
3430 double outer_unmatched_rows;
3443 outer_unmatched_rows = outer_path_rows - outer_matched_rows;
3450 ntuples = outer_matched_rows * inner_path_rows * inner_scan_frac;
3477 run_cost += inner_run_cost * inner_scan_frac;
3478 if (outer_matched_rows > 1)
3479 run_cost += (outer_matched_rows - 1) * inner_rescan_run_cost * inner_scan_frac;
3487 run_cost += outer_unmatched_rows *
3488 inner_rescan_run_cost / inner_path_rows;
3511 ntuples += outer_unmatched_rows * inner_path_rows;
3514 run_cost += inner_run_cost;
3515 if (outer_unmatched_rows >= 1)
3516 outer_unmatched_rows -= 1;
3518 outer_matched_rows -= 1;
3521 if (outer_matched_rows > 0)
3522 run_cost += outer_matched_rows * inner_rescan_run_cost * inner_scan_frac;
3525 if (outer_unmatched_rows > 0)
3526 run_cost += outer_unmatched_rows * inner_rescan_run_cost;
3534 ntuples = outer_path_rows * inner_path_rows;
3539 startup_cost += restrict_qual_cost.
startup;
3541 run_cost += cpu_per_tuple * ntuples;
3544 startup_cost += path->
jpath.path.pathtarget->cost.startup;
3545 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
3547 path->
jpath.path.startup_cost = startup_cost;
3548 path->
jpath.path.total_cost = startup_cost + run_cost;
3587 Path *outer_path,
Path *inner_path,
3588 List *outersortkeys,
List *innersortkeys,
3589 int outer_presorted_keys,
3593 Cost startup_cost = 0;
3595 double outer_path_rows = outer_path->
rows;
3596 double inner_path_rows = inner_path->
rows;
3597 Cost inner_run_cost;
3610 if (outer_path_rows <= 0)
3611 outer_path_rows = 1;
3612 if (inner_path_rows <= 0)
3613 inner_path_rows = 1;
3626 if (mergeclauses && jointype !=
JOIN_FULL)
3636 opathkeys = outersortkeys ? outersortkeys : outer_path->
pathkeys;
3637 ipathkeys = innersortkeys ? innersortkeys : inner_path->
pathkeys;
3644 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation ||
3647 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
3653 outer_path->parent->relids))
3672 outerstartsel = 0.0;
3678 innerstartsel = 0.0;
3685 outerstartsel = innerstartsel = 0.0;
3686 outerendsel = innerendsel = 1.0;
3693 outer_skip_rows = rint(outer_path_rows * outerstartsel);
3694 inner_skip_rows = rint(inner_path_rows * innerstartsel);
3698 Assert(outer_skip_rows <= outer_rows);
3699 Assert(inner_skip_rows <= inner_rows);
3706 outerstartsel = outer_skip_rows / outer_path_rows;
3707 innerstartsel = inner_skip_rows / inner_path_rows;
3708 outerendsel = outer_rows / outer_path_rows;
3709 innerendsel = inner_rows / inner_path_rows;
3711 Assert(outerstartsel <= outerendsel);
3712 Assert(innerstartsel <= innerendsel);
3736 outer_presorted_keys,
3741 outer_path->pathtarget->width,
3754 outer_path->pathtarget->width,
3765 * (outerendsel - outerstartsel);
3774 * (outerendsel - outerstartsel);
3797 inner_path->pathtarget->width,
3806 * (innerendsel - innerstartsel);
3815 * (innerendsel - innerstartsel);
3831 workspace->
total_cost = startup_cost + run_cost + inner_run_cost;
3875 double inner_path_rows = inner_path->
rows;
3890 double mergejointuples,
3898 if (inner_path_rows <= 0)
3899 inner_path_rows = 1;
3902 if (path->
jpath.path.param_info)
3903 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3905 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3908 if (path->
jpath.path.parallel_workers > 0)
3912 path->
jpath.path.rows =
3975 rescannedtuples = 0;
3978 rescannedtuples = mergejointuples - inner_path_rows;
3980 if (rescannedtuples < 0)
3981 rescannedtuples = 0;
3989 rescanratio = 1.0 + (rescannedtuples / inner_rows);
4000 bare_inner_cost = inner_run_cost * rescanratio;
4015 mat_inner_cost = inner_run_cost +
4047 else if (innersortkeys ==
NIL &&
4064 inner_path->pathtarget->width) >
4072 run_cost += mat_inner_cost;
4074 run_cost += bare_inner_cost;
4083 startup_cost += merge_qual_cost.
startup;
4084 startup_cost += merge_qual_cost.
per_tuple *
4085 (outer_skip_rows + inner_skip_rows * rescanratio);
4087 ((outer_rows - outer_skip_rows) +
4088 (inner_rows - inner_skip_rows) * rescanratio);
4099 startup_cost += qp_qual_cost.
startup;
4101 run_cost += cpu_per_tuple * mergejointuples;
4104 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4105 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4107 path->
jpath.path.startup_cost = startup_cost;
4108 path->
jpath.path.total_cost = startup_cost + run_cost;
4126 foreach(lc, rinfo->scansel_cache)
4130 cache->
collation == pathkey->pk_eclass->ec_collation &&
4152 cache->
collation = pathkey->pk_eclass->ec_collation;
4160 rinfo->scansel_cache =
lappend(rinfo->scansel_cache, cache);
4197 Path *outer_path,
Path *inner_path,
4202 Cost startup_cost = 0;
4204 double outer_path_rows = outer_path->
rows;
4205 double inner_path_rows = inner_path->
rows;
4206 double inner_path_rows_total = inner_path_rows;
4211 size_t space_allowed;
4257 inner_path->pathtarget->width,
4275 double outerpages =
page_size(outer_path_rows,
4276 outer_path->pathtarget->width);
4277 double innerpages =
page_size(inner_path_rows,
4278 inner_path->pathtarget->width);
4289 workspace->
total_cost = startup_cost + run_cost;
4315 double outer_path_rows = outer_path->
rows;
4316 double inner_path_rows = inner_path->
rows;
4326 double hashjointuples;
4327 double virtualbuckets;
4336 if (path->
jpath.path.param_info)
4337 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
4339 path->
jpath.path.rows = path->
jpath.path.parent->rows;
4342 if (path->
jpath.path.parallel_workers > 0)
4346 path->
jpath.path.rows =
4357 virtualbuckets = (double) numbuckets * (
double) numbatches;
4372 innerbucketsize = 1.0 / virtualbuckets;
4379 innerbucketsize = 1.0;
4389 foreach(hcl, otherclauses)
4404 inner_path->parent->relids))
4407 thisbucketsize = restrictinfo->right_bucketsize;
4408 if (thisbucketsize < 0)
4414 &restrictinfo->right_mcvfreq,
4415 &restrictinfo->right_bucketsize);
4416 thisbucketsize = restrictinfo->right_bucketsize;
4418 thismcvfreq = restrictinfo->right_mcvfreq;
4423 inner_path->parent->relids));
4425 thisbucketsize = restrictinfo->left_bucketsize;
4426 if (thisbucketsize < 0)
4432 &restrictinfo->left_mcvfreq,
4433 &restrictinfo->left_bucketsize);
4434 thisbucketsize = restrictinfo->left_bucketsize;
4436 thismcvfreq = restrictinfo->left_mcvfreq;
4439 if (innerbucketsize > thisbucketsize)
4440 innerbucketsize = thisbucketsize;
4441 if (innermcvfreq > thismcvfreq)
4442 innermcvfreq = thismcvfreq;
4473 double outer_matched_rows;
4491 startup_cost += hash_qual_cost.
startup;
4492 run_cost += hash_qual_cost.
per_tuple * outer_matched_rows *
4493 clamp_row_est(inner_path_rows * innerbucketsize * inner_scan_frac) * 0.5;
4509 (outer_path_rows - outer_matched_rows) *
4514 hashjointuples = outer_path_rows - outer_matched_rows;
4516 hashjointuples = outer_matched_rows;
4530 startup_cost += hash_qual_cost.
startup;
4531 run_cost += hash_qual_cost.
per_tuple * outer_path_rows *
4548 startup_cost += qp_qual_cost.
startup;
4550 run_cost += cpu_per_tuple * hashjointuples;
4553 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4554 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4556 path->
jpath.path.startup_cost = startup_cost;
4557 path->
jpath.path.total_cost = startup_cost + run_cost;
4621 Cost plan_run_cost =
plan->total_cost -
plan->startup_cost;
4632 sp_cost.
per_tuple += 0.50 * plan_run_cost;
4677 Cost *rescan_startup_cost,
4678 Cost *rescan_total_cost)
4682 case T_FunctionScan:
4691 *rescan_startup_cost = 0;
4700 if (((
HashPath *) path)->num_batches == 1)
4703 *rescan_startup_cost = 0;
4704 *rescan_total_cost = path->total_cost - path->startup_cost;
4709 *rescan_startup_cost = path->startup_cost;
4710 *rescan_total_cost = path->total_cost;
4714 case T_WorkTableScan:
4724 path->pathtarget->width);
4727 if (nbytes > work_mem_bytes)
4730 double npages = ceil(nbytes / BLCKSZ);
4734 *rescan_startup_cost = 0;
4735 *rescan_total_cost = run_cost;
4751 path->pathtarget->width);
4754 if (nbytes > work_mem_bytes)
4757 double npages = ceil(nbytes / BLCKSZ);
4761 *rescan_startup_cost = 0;
4762 *rescan_total_cost = run_cost;
4768 rescan_startup_cost, rescan_total_cost);
4771 *rescan_startup_cost = path->startup_cost;
4772 *rescan_total_cost = path->total_cost;
4809 *cost = context.
total;
4827 *cost = context.
total;
4846 if (rinfo->eval_cost.startup < 0)
4858 if (rinfo->orclause)
4867 if (rinfo->pseudoconstant)
4873 rinfo->eval_cost = locContext.
total;
4993 &iofunc, &typioparam);
4998 &iofunc, &typisvarlena);
5020 foreach(lc, rcexpr->opnos)
5041 elog(
ERROR,
"cannot handle unplanned sub-select");
5175 foreach(l, restrictlist)
5180 joinquals =
lappend(joinquals, rinfo);
5184 joinquals = restrictlist;
5224 avgmatch = nselec * innerrel->
rows / jselec;
5226 avgmatch =
Max(1.0, avgmatch);
5249 Relids joinrelids = joinpath->path.parent->relids;
5259 if (innerpath->param_info == NULL)
5266 case T_IndexOnlyScan:
5267 indexclauses = ((
IndexPath *) innerpath)->indexclauses;
5269 case T_BitmapHeapScan:
5275 indexclauses = ((
IndexPath *) bmqual)->indexclauses;
5297 foreach(lc, innerpath->param_info->ppi_clauses)
5302 innerpath->parent->relids,
5364 tuples = selec * outer_tuples * inner_tuples;
5415 List *param_clauses)
5435 if (nrows > rel->
rows)
5499 List *restrict_clauses)
5521 if (nrows > rel->
rows)
5584 foreach(l, restrictlist)
5589 pushedquals =
lappend(pushedquals, rinfo);
5591 joinquals =
lappend(joinquals, rinfo);
5635 nrows = outer_rows * inner_rows * fkselec * jselec;
5639 nrows = outer_rows * inner_rows * fkselec * jselec;
5640 if (nrows < outer_rows)
5645 nrows = outer_rows * inner_rows * fkselec * jselec;
5646 if (nrows < outer_rows)
5648 if (nrows < inner_rows)
5653 nrows = outer_rows * fkselec * jselec;
5657 nrows = outer_rows * (1.0 - fkselec * jselec);
5662 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
5690 List **restrictlist)
5694 List *worklist = *restrictlist;
5698 foreach(lc,
root->fkey_list)
5711 ref_is_outer =
false;
5714 ref_is_outer =
true;
5740 if (worklist == *restrictlist)
5744 foreach(cell, worklist)
5747 bool remove_it =
false;
5751 for (
i = 0;
i < fkinfo->
nkeys;
i++)
5753 if (rinfo->parent_ec)
5768 if (fkinfo->
eclass[
i] == rinfo->parent_ec)
5790 removedlist =
lappend(removedlist, rinfo);
5820 if (removedlist ==
NIL ||
5865 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5867 fkselec *= ref_rel->
rows / ref_tuples;
5877 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5879 fkselec *= 1.0 / ref_tuples;
5894 for (
int i = 0;
i < fkinfo->
nkeys;
i++)
5922 *restrictlist = worklist;
5965 int32 item_width = 0;
5996 Var *var = (
Var *) texpr;
6119 if (rte->self_reference)
6163 rel->
tuples = rte->enrtuples;
6248 int64 tuple_width = 0;
6249 bool have_wholerow_var =
false;
6267 ((
Var *) node)->varno == rel->
relid)
6284 have_wholerow_var =
true;
6292 if (rel->attr_widths[ndx] > 0)
6294 tuple_width += rel->attr_widths[ndx];
6304 rel->attr_widths[ndx] = item_width;
6305 tuple_width += item_width;
6316 rel->attr_widths[ndx] = item_width;
6317 tuple_width += item_width;
6346 tuple_width += item_width;
6358 if (have_wholerow_var)
6374 wholerow_width += rel->attr_widths[
i - rel->
min_attr];
6383 tuple_width += wholerow_width;
6404 int64 tuple_width = 0;
6411 foreach(lc, target->
exprs)
6446 const Var *var = (
const Var *) expr;
6453 var->
varno <
root->simple_rel_array_size)
6463 if (rel->attr_widths[ndx] > 0)
6464 return rel->attr_widths[ndx];
6526 double leader_contribution;
6529 if (leader_contribution > 0)
6530 parallel_divisor += leader_contribution;
6533 return parallel_divisor;
6550 Path *bitmapqual,
double loop_count,
6551 Cost *cost_p,
double *tuples_p)
6553 Cost indexTotalCost;
6556 double pages_fetched;
6557 double tuples_fetched;
6572 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
6579 pages_fetched = (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
6589 heap_pages =
Min(pages_fetched, baserel->
pages);
6604 pages_fetched /= loop_count;
6607 if (pages_fetched >=
T)
6610 pages_fetched = ceil(pages_fetched);
6612 if (maxentries < heap_pages)
6624 lossy_pages =
Max(0, heap_pages - maxentries / 2);
6625 exact_pages = heap_pages - lossy_pages;
6634 if (lossy_pages > 0)
6637 (exact_pages / heap_pages) * baserel->
tuples +
6638 (lossy_pages / heap_pages) * baserel->
tuples);
6642 *cost_p = indexTotalCost;
6644 *tuples_p = tuples_fetched;
6646 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)
long clamp_cardinality_to_long(Cardinality x)
void cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root)
bool enable_partition_pruning
int32 clamp_width_est(int64 tuple_width)
double cpu_index_tuple_cost
void set_tablefunc_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void cost_index(IndexPath *path, PlannerInfo *root, double loop_count, bool partial_path)
void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel)
static Selectivity get_foreign_key_join_selectivity(PlannerInfo *root, Relids outer_relids, Relids inner_relids, SpecialJoinInfo *sjinfo, List **restrictlist)
bool enable_incremental_sort
static int32 get_expr_width(PlannerInfo *root, const Node *expr)
bool is_redundant_with_indexclauses(RestrictInfo *rinfo, List *indexclauses)
RestrictInfo * find_derived_clause_for_ec_member(PlannerInfo *root, EquivalenceClass *ec, EquivalenceMember *em)
bool ExecSupportsMarkRestore(Path *pathnode)
bool ExecMaterializesOutput(NodeTag plantype)
Assert(PointerIsAligned(start, uint64))
#define SizeofHeapTupleHeader
if(TABLE==NULL||TABLE_index==NULL)
void init_dummy_sjinfo(SpecialJoinInfo *sjinfo, Relids left_relids, Relids right_relids)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
List * list_copy(const List *oldlist)
bool list_member_ptr(const List *list, const void *datum)
void list_free(List *list)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
int32 get_attavgwidth(Oid relid, AttrNumber attnum)
RegProcedure get_opcode(Oid opno)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
int32 get_typavgwidth(Oid typid, int32 typmod)
Datum subpath(PG_FUNCTION_ARGS)
List * make_ands_implicit(Expr *clause)
static const uint32 T[65]
Size hash_agg_entry_size(int numTrans, Size tupleWidth, Size transitionSpace)
void hash_agg_set_limits(double hashentrysize, double input_groups, int used_bits, Size *mem_limit, uint64 *ngroups_limit, int *num_partitions)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
void set_sa_opfuncid(ScalarArrayOpExpr *opexpr)
void set_opfuncid(OpExpr *opexpr)
static Node * get_rightop(const void *clause)
#define expression_tree_walker(n, w, c)
static Node * get_leftop(const void *clause)
void ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew, bool try_combined_hash_mem, int parallel_workers, size_t *space_allowed, int *numbuckets, int *numbatches, int *num_skew_mcvs)
size_t get_hash_memory_limit(void)
double ExecEstimateCacheEntryOverheadBytes(double ntuples)
#define IsA(nodeptr, _type_)
#define IS_OUTER_JOIN(jointype)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define FRAMEOPTION_END_CURRENT_ROW
#define FRAMEOPTION_END_OFFSET_PRECEDING
#define FRAMEOPTION_END_OFFSET_FOLLOWING
#define FRAMEOPTION_RANGE
#define FRAMEOPTION_GROUPS
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
bool pathkeys_count_contained_in(List *keys1, List *keys2, int *n_common)
bool pathkeys_contained_in(List *keys1, List *keys2)
#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids)
#define planner_rt_fetch(rti, root)
#define 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)