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;
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;
1254 bool isCurrentOf =
false;
1260 double spc_random_page_cost;
1274 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;
1363 Cost startup_cost = 0;
1370 double spc_random_page_cost;
1371 double spc_seq_page_cost;
1386 pages = ceil(selectivity * baserel->
pages);
1399 ntuples = selectivity * baserel->
tuples;
1400 nseqpages = pages - 1.0;
1413 &spc_random_page_cost,
1414 &spc_seq_page_cost);
1417 run_cost += spc_random_page_cost + spc_seq_page_cost * nseqpages;
1432 run_cost += cpu_per_tuple * ntuples;
1435 startup_cost += path->pathtarget->cost.startup;
1436 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1453 bool trivial_pathtarget)
1506 if (qpquals ==
NIL && trivial_pathtarget)
1511 startup_cost = qpqual_cost.
startup;
1516 startup_cost += path->
path.pathtarget->cost.startup;
1517 run_cost += path->
path.pathtarget->cost.per_tuple * path->
path.
rows;
1534 Cost startup_cost = 0;
1572 startup_cost += qpqual_cost.
startup;
1574 run_cost += cpu_per_tuple * baserel->
tuples;
1577 startup_cost += path->pathtarget->cost.startup;
1578 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1595 Cost startup_cost = 0;
1628 startup_cost += qpqual_cost.
startup;
1630 run_cost += cpu_per_tuple * baserel->
tuples;
1633 startup_cost += path->pathtarget->cost.startup;
1634 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1651 Cost startup_cost = 0;
1675 startup_cost += qpqual_cost.
startup;
1677 run_cost += cpu_per_tuple * baserel->
tuples;
1680 startup_cost += path->pathtarget->cost.startup;
1681 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1701 Cost startup_cost = 0;
1722 startup_cost += qpqual_cost.
startup;
1724 run_cost += cpu_per_tuple * baserel->
tuples;
1727 startup_cost += path->pathtarget->cost.startup;
1728 run_cost += path->pathtarget->cost.per_tuple * path->
rows;
1742 Cost startup_cost = 0;
1763 startup_cost += qpqual_cost.
startup;
1765 run_cost += cpu_per_tuple * baserel->
tuples;
1779 Cost startup_cost = 0;
1797 startup_cost += qpqual_cost.
startup;
1799 run_cost += cpu_per_tuple * baserel->
tuples;
1822 total_rows = nrterm->
rows;
1831 total_rows += 10 * rterm->
rows;
1842 runion->
rows = total_rows;
1843 runion->pathtarget->width =
Max(nrterm->pathtarget->width,
1844 rterm->pathtarget->width);
1885 double tuples,
int width,
1886 Cost comparison_cost,
int sort_mem,
1887 double limit_tuples)
1890 double output_bytes;
1891 double output_tuples;
1892 long sort_mem_bytes = sort_mem * 1024L;
1905 if (limit_tuples > 0 && limit_tuples < tuples)
1907 output_tuples = limit_tuples;
1912 output_tuples = tuples;
1913 output_bytes = input_bytes;
1916 if (output_bytes > sort_mem_bytes)
1921 double npages = ceil(input_bytes / BLCKSZ);
1922 double nruns = input_bytes / sort_mem_bytes;
1925 double npageaccesses;
1932 *startup_cost = comparison_cost * tuples *
LOG2(tuples);
1937 if (nruns > mergeorder)
1938 log_runs = ceil(log(nruns) / log(mergeorder));
1941 npageaccesses = 2.0 * npages * log_runs;
1943 *startup_cost += npageaccesses *
1946 else if (tuples > 2 * output_tuples || input_bytes > sort_mem_bytes)
1954 *startup_cost = comparison_cost * tuples *
LOG2(2.0 * output_tuples);
1959 *startup_cost = comparison_cost * tuples *
LOG2(tuples);
1988 Cost input_startup_cost,
Cost input_total_cost,
1989 double input_tuples,
int width,
Cost comparison_cost,
int sort_mem,
1990 double limit_tuples)
1994 input_run_cost = input_total_cost - input_startup_cost;
1995 double group_tuples,
1997 Cost group_startup_cost,
1999 group_input_run_cost;
2002 bool unknown_varno =
false;
2010 if (input_tuples < 2.0)
2038 foreach(l, pathkeys)
2050 unknown_varno =
true;
2066 group_tuples = input_tuples / input_groups;
2067 group_input_run_cost = input_run_cost / input_groups;
2074 group_tuples, width, comparison_cost, sort_mem,
2081 startup_cost = group_startup_cost + input_startup_cost +
2082 group_input_run_cost;
2090 run_cost = group_run_cost + (group_run_cost + group_startup_cost) *
2091 (input_groups - 1) + group_input_run_cost * (input_groups - 1);
2106 path->
rows = input_tuples;
2125 List *pathkeys,
Cost input_cost,
double tuples,
int width,
2126 Cost comparison_cost,
int sort_mem,
2127 double limit_tuples)
2135 comparison_cost, sort_mem,
2141 startup_cost += input_cost;
2143 path->
rows = tuples;
2172 arrlen =
Min(parallel_workers, numpaths);
2177 foreach(cell, subpaths)
2181 if (path_index == arrlen)
2183 costarr[path_index++] =
subpath->total_cost;
2190 min_index = arrlen - 1;
2201 if (path_index++ == numpaths)
2204 costarr[min_index] +=
subpath->total_cost;
2208 for (
int i = 0;
i < arrlen;
i++)
2210 if (costarr[
i] < costarr[min_index])
2217 for (
int i = 0;
i < arrlen;
i++)
2219 if (costarr[
i] > costarr[max_index])
2223 return costarr[max_index];
2246 if (pathkeys ==
NIL)
2336 else if (i < apath->path.parallel_workers)
2347 if (i < apath->first_partial_path)
2351 double subpath_parallel_divisor;
2405 List *pathkeys,
int n_streams,
2406 Cost input_startup_cost,
Cost input_total_cost,
2409 Cost startup_cost = 0;
2411 Cost comparison_cost;
2418 N = (n_streams < 2) ? 2.0 : (
double) n_streams;
2425 startup_cost += comparison_cost * N * logN;
2428 run_cost += tuples * comparison_cost * logN;
2436 path->
startup_cost = startup_cost + input_startup_cost;
2437 path->
total_cost = startup_cost + run_cost + input_total_cost;
2454 Cost input_startup_cost,
Cost input_total_cost,
2455 double tuples,
int width)
2457 Cost startup_cost = input_startup_cost;
2458 Cost run_cost = input_total_cost - input_startup_cost;
2460 long work_mem_bytes =
work_mem * 1024L;
2462 path->
rows = tuples;
2484 if (nbytes > work_mem_bytes)
2486 double npages = ceil(nbytes / BLCKSZ);
2510 Cost *rescan_startup_cost,
Cost *rescan_total_cost)
2517 double calls = mpath->
calls;
2518 int width = mpath->
subpath->pathtarget->width;
2520 double hash_mem_bytes;
2521 double est_entry_bytes;
2522 double est_cache_entries;
2546 est_cache_entries = floor(hash_mem_bytes / est_entry_bytes);
2581 evict_ratio = 1.0 -
Min(est_cache_entries, ndistinct) / ndistinct;
2589 hit_ratio = ((calls - ndistinct) / calls) *
2590 (est_cache_entries /
Max(ndistinct, est_cache_entries));
2592 Assert(hit_ratio >= 0 && hit_ratio <= 1.0);
2626 startup_cost = input_startup_cost * (1.0 - hit_ratio);
2634 *rescan_startup_cost = startup_cost;
2635 *rescan_total_cost = total_cost;
2652 int numGroupCols,
double numGroups,
2654 Cost input_startup_cost,
Cost input_total_cost,
2655 double input_tuples,
double input_width)
2657 double output_tuples;
2663 if (aggcosts == NULL)
2667 aggcosts = &dummy_aggcosts;
2694 startup_cost = input_total_cost;
2706 startup_cost = input_startup_cost;
2707 total_cost = input_total_cost;
2720 output_tuples = numGroups;
2725 startup_cost = input_total_cost;
2734 total_cost = startup_cost;
2738 output_tuples = numGroups;
2757 double pages_written = 0.0;
2758 double pages_read = 0.0;
2760 double hashentrysize;
2763 uint64 ngroups_limit;
2776 &ngroups_limit, &num_partitions);
2778 nbatches =
Max((numGroups * hashentrysize) / mem_limit,
2779 numGroups / ngroups_limit);
2781 nbatches =
Max(ceil(nbatches), 1.0);
2782 num_partitions =
Max(num_partitions, 2);
2789 depth = ceil(log(nbatches) / log(num_partitions));
2796 pages_written = pages_read = pages * depth;
2803 pages_written *= 2.0;
2811 startup_cost += spill_cost;
2812 total_cost += spill_cost;
2824 startup_cost += qual_cost.
startup;
2835 path->
rows = output_tuples;
2855 double input_tuples)
2858 double partition_tuples;
2859 double return_tuples;
2868 double num_partitions;
2876 partition_tuples = input_tuples / num_partitions;
2881 partition_tuples = input_tuples;
2895 partition_tuples, NULL,
2898 peer_tuples = partition_tuples / num_groups;
2909 return_tuples = partition_tuples;
2916 return_tuples = 1.0;
2926 return_tuples = partition_tuples;
2928 return_tuples = peer_tuples;
2937 return_tuples = 1.0;
2948 return_tuples = 1.0;
2953 double end_offset_value;
2958 if (endOffset->constisnull)
2967 end_offset_value = 1.0;
2987 partition_tuples / peer_tuples *
3006 return_tuples = end_offset_value + 1.0;
3011 return_tuples = peer_tuples * (end_offset_value + 1.0);
3020 return_tuples = 1.0;
3030 return_tuples = 1.0;
3040 return_tuples =
Min(return_tuples + 1.0, partition_tuples);
3048 return_tuples =
Min(return_tuples, partition_tuples);
3070 Cost input_startup_cost,
Cost input_total_cost,
3071 double input_tuples)
3075 double startup_tuples;
3083 startup_cost = input_startup_cost;
3084 total_cost = input_total_cost;
3095 foreach(lc, windowFuncs)
3104 startup_cost += argcosts.
startup;
3109 startup_cost += argcosts.
startup;
3117 startup_cost += argcosts.
startup;
3120 total_cost += wfunccost * input_tuples;
3134 path->
rows = input_tuples;
3149 if (startup_tuples > 1.0)
3150 path->
startup_cost += (total_cost - startup_cost) / input_tuples *
3151 (startup_tuples - 1.0);
3164 int numGroupCols,
double numGroups,
3166 Cost input_startup_cost,
Cost input_total_cost,
3167 double input_tuples)
3169 double output_tuples;
3173 output_tuples = numGroups;
3174 startup_cost = input_startup_cost;
3175 total_cost = input_total_cost;
3192 startup_cost += qual_cost.
startup;
3203 path->
rows = output_tuples;
3235 Path *outer_path,
Path *inner_path,
3238 Cost startup_cost = 0;
3240 double outer_path_rows = outer_path->
rows;
3241 Cost inner_rescan_start_cost;
3242 Cost inner_rescan_total_cost;
3243 Cost inner_run_cost;
3244 Cost inner_rescan_run_cost;
3248 &inner_rescan_start_cost,
3249 &inner_rescan_total_cost);
3261 if (outer_path_rows > 1)
3262 run_cost += (outer_path_rows - 1) * inner_rescan_start_cost;
3265 inner_rescan_run_cost = inner_rescan_total_cost - inner_rescan_start_cost;
3285 run_cost += inner_run_cost;
3286 if (outer_path_rows > 1)
3287 run_cost += (outer_path_rows - 1) * inner_rescan_run_cost;
3294 workspace->
total_cost = startup_cost + run_cost;
3314 double outer_path_rows = outer_path->
rows;
3315 double inner_path_rows = inner_path->
rows;
3323 if (outer_path_rows <= 0)
3324 outer_path_rows = 1;
3325 if (inner_path_rows <= 0)
3326 inner_path_rows = 1;
3328 if (path->
jpath.path.param_info)
3329 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3331 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3334 if (path->
jpath.path.parallel_workers > 0)
3338 path->
jpath.path.rows =
3361 double outer_matched_rows;
3362 double outer_unmatched_rows;
3375 outer_unmatched_rows = outer_path_rows - outer_matched_rows;
3382 ntuples = outer_matched_rows * inner_path_rows * inner_scan_frac;
3409 run_cost += inner_run_cost * inner_scan_frac;
3410 if (outer_matched_rows > 1)
3411 run_cost += (outer_matched_rows - 1) * inner_rescan_run_cost * inner_scan_frac;
3419 run_cost += outer_unmatched_rows *
3420 inner_rescan_run_cost / inner_path_rows;
3443 ntuples += outer_unmatched_rows * inner_path_rows;
3446 run_cost += inner_run_cost;
3447 if (outer_unmatched_rows >= 1)
3448 outer_unmatched_rows -= 1;
3450 outer_matched_rows -= 1;
3453 if (outer_matched_rows > 0)
3454 run_cost += outer_matched_rows * inner_rescan_run_cost * inner_scan_frac;
3457 if (outer_unmatched_rows > 0)
3458 run_cost += outer_unmatched_rows * inner_rescan_run_cost;
3466 ntuples = outer_path_rows * inner_path_rows;
3471 startup_cost += restrict_qual_cost.
startup;
3473 run_cost += cpu_per_tuple * ntuples;
3476 startup_cost += path->
jpath.path.pathtarget->cost.startup;
3477 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
3479 path->
jpath.path.startup_cost = startup_cost;
3480 path->
jpath.path.total_cost = startup_cost + run_cost;
3517 Path *outer_path,
Path *inner_path,
3518 List *outersortkeys,
List *innersortkeys,
3521 Cost startup_cost = 0;
3523 double outer_path_rows = outer_path->
rows;
3524 double inner_path_rows = inner_path->
rows;
3525 Cost inner_run_cost;
3537 if (outer_path_rows <= 0)
3538 outer_path_rows = 1;
3539 if (inner_path_rows <= 0)
3540 inner_path_rows = 1;
3553 if (mergeclauses && jointype !=
JOIN_FULL)
3563 opathkeys = outersortkeys ? outersortkeys : outer_path->
pathkeys;
3564 ipathkeys = innersortkeys ? innersortkeys : inner_path->
pathkeys;
3571 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation ||
3574 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
3580 outer_path->parent->relids))
3599 outerstartsel = 0.0;
3605 innerstartsel = 0.0;
3612 outerstartsel = innerstartsel = 0.0;
3613 outerendsel = innerendsel = 1.0;
3620 outer_skip_rows = rint(outer_path_rows * outerstartsel);
3621 inner_skip_rows = rint(inner_path_rows * innerstartsel);
3625 Assert(outer_skip_rows <= outer_rows);
3626 Assert(inner_skip_rows <= inner_rows);
3633 outerstartsel = outer_skip_rows / outer_path_rows;
3634 innerstartsel = inner_skip_rows / inner_path_rows;
3635 outerendsel = outer_rows / outer_path_rows;
3636 innerendsel = inner_rows / inner_path_rows;
3638 Assert(outerstartsel <= outerendsel);
3639 Assert(innerstartsel <= innerendsel);
3650 outer_path->pathtarget->width,
3658 * (outerendsel - outerstartsel);
3666 * (outerendsel - outerstartsel);
3676 inner_path->pathtarget->width,
3684 * (innerendsel - innerstartsel);
3692 * (innerendsel - innerstartsel);
3707 workspace->
total_cost = startup_cost + run_cost + inner_run_cost;
3751 double inner_path_rows = inner_path->
rows;
3766 double mergejointuples,
3771 if (inner_path_rows <= 0)
3772 inner_path_rows = 1;
3775 if (path->
jpath.path.param_info)
3776 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
3778 path->
jpath.path.rows = path->
jpath.path.parent->rows;
3781 if (path->
jpath.path.parallel_workers > 0)
3785 path->
jpath.path.rows =
3854 rescannedtuples = 0;
3857 rescannedtuples = mergejointuples - inner_path_rows;
3859 if (rescannedtuples < 0)
3860 rescannedtuples = 0;
3868 rescanratio = 1.0 + (rescannedtuples / inner_rows);
3879 bare_inner_cost = inner_run_cost * rescanratio;
3894 mat_inner_cost = inner_run_cost +
3926 else if (innersortkeys ==
NIL &&
3943 inner_path->pathtarget->width) >
3951 run_cost += mat_inner_cost;
3953 run_cost += bare_inner_cost;
3962 startup_cost += merge_qual_cost.
startup;
3963 startup_cost += merge_qual_cost.
per_tuple *
3964 (outer_skip_rows + inner_skip_rows * rescanratio);
3966 ((outer_rows - outer_skip_rows) +
3967 (inner_rows - inner_skip_rows) * rescanratio);
3978 startup_cost += qp_qual_cost.
startup;
3980 run_cost += cpu_per_tuple * mergejointuples;
3983 startup_cost += path->
jpath.path.pathtarget->cost.startup;
3984 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
3986 path->
jpath.path.startup_cost = startup_cost;
3987 path->
jpath.path.total_cost = startup_cost + run_cost;
4005 foreach(lc, rinfo->scansel_cache)
4009 cache->
collation == pathkey->pk_eclass->ec_collation &&
4031 cache->
collation = pathkey->pk_eclass->ec_collation;
4039 rinfo->scansel_cache =
lappend(rinfo->scansel_cache, cache);
4076 Path *outer_path,
Path *inner_path,
4080 Cost startup_cost = 0;
4082 double outer_path_rows = outer_path->
rows;
4083 double inner_path_rows = inner_path->
rows;
4084 double inner_path_rows_total = inner_path_rows;
4089 size_t space_allowed;
4130 inner_path->pathtarget->width,
4148 double outerpages =
page_size(outer_path_rows,
4149 outer_path->pathtarget->width);
4150 double innerpages =
page_size(inner_path_rows,
4151 inner_path->pathtarget->width);
4161 workspace->
total_cost = startup_cost + run_cost;
4187 double outer_path_rows = outer_path->
rows;
4188 double inner_path_rows = inner_path->
rows;
4198 double hashjointuples;
4199 double virtualbuckets;
4205 if (path->
jpath.path.param_info)
4206 path->
jpath.path.rows = path->
jpath.path.param_info->ppi_rows;
4208 path->
jpath.path.rows = path->
jpath.path.parent->rows;
4211 if (path->
jpath.path.parallel_workers > 0)
4215 path->
jpath.path.rows =
4234 virtualbuckets = (double) numbuckets * (
double) numbatches;
4248 innerbucketsize = 1.0 / virtualbuckets;
4253 innerbucketsize = 1.0;
4255 foreach(hcl, hashclauses)
4270 inner_path->parent->relids))
4273 thisbucketsize = restrictinfo->right_bucketsize;
4274 if (thisbucketsize < 0)
4280 &restrictinfo->right_mcvfreq,
4281 &restrictinfo->right_bucketsize);
4282 thisbucketsize = restrictinfo->right_bucketsize;
4284 thismcvfreq = restrictinfo->right_mcvfreq;
4289 inner_path->parent->relids));
4291 thisbucketsize = restrictinfo->left_bucketsize;
4292 if (thisbucketsize < 0)
4298 &restrictinfo->left_mcvfreq,
4299 &restrictinfo->left_bucketsize);
4300 thisbucketsize = restrictinfo->left_bucketsize;
4302 thismcvfreq = restrictinfo->left_mcvfreq;
4305 if (innerbucketsize > thisbucketsize)
4306 innerbucketsize = thisbucketsize;
4307 if (innermcvfreq > thismcvfreq)
4308 innermcvfreq = thismcvfreq;
4339 double outer_matched_rows;
4357 startup_cost += hash_qual_cost.
startup;
4358 run_cost += hash_qual_cost.
per_tuple * outer_matched_rows *
4359 clamp_row_est(inner_path_rows * innerbucketsize * inner_scan_frac) * 0.5;
4375 (outer_path_rows - outer_matched_rows) *
4380 hashjointuples = outer_path_rows - outer_matched_rows;
4382 hashjointuples = outer_matched_rows;
4396 startup_cost += hash_qual_cost.
startup;
4397 run_cost += hash_qual_cost.
per_tuple * outer_path_rows *
4414 startup_cost += qp_qual_cost.
startup;
4416 run_cost += cpu_per_tuple * hashjointuples;
4419 startup_cost += path->
jpath.path.pathtarget->cost.startup;
4420 run_cost += path->
jpath.path.pathtarget->cost.per_tuple * path->
jpath.path.rows;
4422 path->
jpath.path.startup_cost = startup_cost;
4423 path->
jpath.path.total_cost = startup_cost + run_cost;
4473 Cost plan_run_cost =
plan->total_cost -
plan->startup_cost;
4484 sp_cost.
per_tuple += 0.50 * plan_run_cost;
4529 Cost *rescan_startup_cost,
4530 Cost *rescan_total_cost)
4534 case T_FunctionScan:
4543 *rescan_startup_cost = 0;
4552 if (((
HashPath *) path)->num_batches == 1)
4555 *rescan_startup_cost = 0;
4556 *rescan_total_cost = path->total_cost - path->startup_cost;
4561 *rescan_startup_cost = path->startup_cost;
4562 *rescan_total_cost = path->total_cost;
4566 case T_WorkTableScan:
4576 path->pathtarget->width);
4577 long work_mem_bytes =
work_mem * 1024L;
4579 if (nbytes > work_mem_bytes)
4582 double npages = ceil(nbytes / BLCKSZ);
4586 *rescan_startup_cost = 0;
4587 *rescan_total_cost = run_cost;
4603 path->pathtarget->width);
4604 long work_mem_bytes =
work_mem * 1024L;
4606 if (nbytes > work_mem_bytes)
4609 double npages = ceil(nbytes / BLCKSZ);
4613 *rescan_startup_cost = 0;
4614 *rescan_total_cost = run_cost;
4620 rescan_startup_cost, rescan_total_cost);
4623 *rescan_startup_cost = path->startup_cost;
4624 *rescan_total_cost = path->total_cost;
4645 context.
root = root;
4658 *cost = context.
total;
4670 context.
root = root;
4676 *cost = context.
total;
4695 if (rinfo->eval_cost.startup < 0)
4707 if (rinfo->orclause)
4716 if (rinfo->pseudoconstant)
4722 rinfo->eval_cost = locContext.
total;
4842 &iofunc, &typioparam);
4847 &iofunc, &typisvarlena);
4869 foreach(lc, rcexpr->opnos)
4894 elog(
ERROR,
"cannot handle unplanned sub-select");
5029 foreach(l, restrictlist)
5034 joinquals =
lappend(joinquals, rinfo);
5038 joinquals = restrictlist;
5052 norm_sjinfo.type = T_SpecialJoinInfo;
5094 avgmatch = nselec * innerrel->
rows / jselec;
5096 avgmatch =
Max(1.0, avgmatch);
5119 Relids joinrelids = joinpath->path.parent->relids;
5129 if (innerpath->param_info == NULL)
5136 case T_IndexOnlyScan:
5137 indexclauses = ((
IndexPath *) innerpath)->indexclauses;
5139 case T_BitmapHeapScan:
5145 indexclauses = ((
IndexPath *) bmqual)->indexclauses;
5167 foreach(lc, innerpath->param_info->ppi_clauses)
5172 innerpath->parent->relids,
5221 sjinfo.type = T_SpecialJoinInfo;
5249 tuples = selec * outer_tuples * inner_tuples;
5300 List *param_clauses)
5320 if (nrows > rel->
rows)
5384 List *restrict_clauses)
5406 if (nrows > rel->
rows)
5469 foreach(l, restrictlist)
5474 pushedquals =
lappend(pushedquals, rinfo);
5476 joinquals =
lappend(joinquals, rinfo);
5520 nrows = outer_rows * inner_rows * fkselec * jselec;
5524 nrows = outer_rows * inner_rows * fkselec * jselec;
5525 if (nrows < outer_rows)
5530 nrows = outer_rows * inner_rows * fkselec * jselec;
5531 if (nrows < outer_rows)
5533 if (nrows < inner_rows)
5538 nrows = outer_rows * fkselec * jselec;
5542 nrows = outer_rows * (1.0 - fkselec * jselec);
5547 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
5575 List **restrictlist)
5579 List *worklist = *restrictlist;
5596 ref_is_outer =
false;
5599 ref_is_outer =
true;
5625 if (worklist == *restrictlist)
5629 foreach(cell, worklist)
5632 bool remove_it =
false;
5636 for (
i = 0;
i < fkinfo->
nkeys;
i++)
5638 if (rinfo->parent_ec)
5653 if (fkinfo->
eclass[
i] == rinfo->parent_ec)
5675 removedlist =
lappend(removedlist, rinfo);
5705 if (removedlist ==
NIL ||
5750 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5752 fkselec *= ref_rel->
rows / ref_tuples;
5762 double ref_tuples =
Max(ref_rel->
tuples, 1.0);
5764 fkselec *= 1.0 / ref_tuples;
5779 for (
int i = 0;
i < fkinfo->
nkeys;
i++)
5806 *restrictlist = worklist;
5849 int32 item_width = 0;
5880 Var *var = (
Var *) texpr;
6132 int64 tuple_width = 0;
6133 bool have_wholerow_var =
false;
6151 ((
Var *) node)->varno == rel->
relid)
6168 have_wholerow_var =
true;
6176 if (rel->attr_widths[ndx] > 0)
6178 tuple_width += rel->attr_widths[ndx];
6188 rel->attr_widths[ndx] = item_width;
6189 tuple_width += item_width;
6200 rel->attr_widths[ndx] = item_width;
6201 tuple_width += item_width;
6230 tuple_width += item_width;
6242 if (have_wholerow_var)
6258 wholerow_width += rel->attr_widths[
i - rel->
min_attr];
6267 tuple_width += wholerow_width;
6288 int64 tuple_width = 0;
6295 foreach(lc, target->
exprs)
6330 const Var *var = (
const Var *) expr;
6347 if (rel->attr_widths[ndx] > 0)
6348 return rel->attr_widths[ndx];
6410 double leader_contribution;
6413 if (leader_contribution > 0)
6414 parallel_divisor += leader_contribution;
6417 return parallel_divisor;
6434 Path *bitmapqual,
double loop_count,
6435 Cost *cost_p,
double *tuples_p)
6437 Cost indexTotalCost;
6440 double pages_fetched;
6441 double tuples_fetched;
6456 T = (baserel->
pages > 1) ? (
double) baserel->
pages : 1.0;
6463 pages_fetched = (2.0 *
T * tuples_fetched) / (2.0 *
T + tuples_fetched);
6473 heap_pages =
Min(pages_fetched, baserel->
pages);
6488 pages_fetched /= loop_count;
6491 if (pages_fetched >=
T)
6494 pages_fetched = ceil(pages_fetched);
6496 if (maxentries < heap_pages)
6508 lossy_pages =
Max(0, heap_pages - maxentries / 2);
6509 exact_pages = heap_pages - lossy_pages;
6518 if (lossy_pages > 0)
6521 (exact_pages / heap_pages) * baserel->
tuples +
6522 (lossy_pages / heap_pages) * baserel->
tuples);
6526 *cost_p = indexTotalCost;
6528 *tuples_p = tuples_fetched;
6530 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 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)
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)
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define FRAMEOPTION_END_CURRENT_ROW
#define FRAMEOPTION_END_OFFSET_PRECEDING
#define FRAMEOPTION_END_OFFSET_FOLLOWING
#define FRAMEOPTION_RANGE
#define FRAMEOPTION_GROUPS
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
bool pathkeys_contained_in(List *keys1, List *keys2)
#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids)
#define planner_rt_fetch(rti, root)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define foreach_current_index(var_or_cell)
#define foreach_delete_current(lst, var_or_cell)
#define for_each_cell(cell, lst, initcell)
static ListCell * list_head(const List *l)
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv)
void add_function_cost(PlannerInfo *root, Oid funcid, Node *node, QualCost *cost)
int32 get_relation_data_width(Oid relid, int32 *attr_widths)
bool parallel_leader_participation
static int64 DatumGetInt64(Datum X)
static int16 DatumGetInt16(Datum X)
static int32 DatumGetInt32(Datum X)
#define IS_SPECIAL_VARNO(varno)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
bool join_clause_is_movable_into(RestrictInfo *rinfo, Relids currentrelids, Relids current_and_outer)
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
int simple_rel_array_size
Cardinality total_table_pages
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)