* cost_tablefunction * Determines and returns the cost of scanning a table function RTE. */
| 1644 | * Determines and returns the cost of scanning a table function RTE. |
| 1645 | */ |
| 1646 | void |
| 1647 | cost_tablefunction(TableFunctionScanPath *path, PlannerInfo *root, RelOptInfo *baserel_orig, |
| 1648 | ParamPathInfo *param_info_orig) |
| 1649 | { |
| 1650 | ADJUST_BASESCAN(baserel_orig, baserel, param_info_orig, param_info); |
| 1651 | Cost startup_cost; |
| 1652 | Cost run_cost; |
| 1653 | QualCost qpqual_cost; |
| 1654 | Cost cpu_per_tuple; |
| 1655 | |
| 1656 | /* Should only be applied to base relations that are functions */ |
| 1657 | Assert(baserel->relid > 0); |
| 1658 | Assert(baserel->rtekind == RTE_TABLEFUNCTION); |
| 1659 | |
| 1660 | /* Mark the path with the correct row estimate */ |
| 1661 | if (param_info) |
| 1662 | path->path.rows = param_info->ppi_rows; |
| 1663 | else |
| 1664 | path->path.rows = baserel->rows; |
| 1665 | |
| 1666 | /* Initialize cost of the subquery input */ |
| 1667 | path->path.startup_cost = path->subpath->startup_cost; |
| 1668 | path->path.total_cost = path->subpath->total_cost; |
| 1669 | |
| 1670 | /* |
| 1671 | * For now, estimate function's cost at one operator eval per function |
| 1672 | * call. Someday we should revive the function cost estimate columns in |
| 1673 | * pg_proc... (see cost_functionscan above) |
| 1674 | */ |
| 1675 | cpu_per_tuple = cpu_operator_cost; |
| 1676 | |
| 1677 | /* Calculate additional cost of the table function node */ |
| 1678 | get_restriction_qual_cost(root, baserel_orig, param_info_orig, &qpqual_cost); |
| 1679 | |
| 1680 | startup_cost = qpqual_cost.startup; |
| 1681 | cpu_per_tuple = cpu_tuple_cost + qpqual_cost.per_tuple; |
| 1682 | run_cost = cpu_per_tuple * baserel->tuples; |
| 1683 | |
| 1684 | /* Add in the additional cost */ |
| 1685 | path->path.startup_cost += startup_cost; |
| 1686 | path->path.total_cost += startup_cost + run_cost; |
| 1687 | } |
| 1688 | |
| 1689 | /* |
| 1690 | * cost_tablefuncscan |
no test coverage detected