From: Tom Lane Date: Wed, 5 Oct 2005 17:19:19 +0000 (+0000) Subject: Make set_function_size_estimates() marginally smarter: per original X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=42e6ace12c11242c7d9e990d7a3efa33363451d5;p=users%2Fbernd%2Fpostgres.git Make set_function_size_estimates() marginally smarter: per original comment, it can at least test whether the expression returns set. --- diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 75b6928209..77af01491b 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -1898,17 +1898,23 @@ join_in_selectivity(JoinPath *path, PlannerInfo *root) void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel) { + RangeTblEntry *rte; + /* Should only be applied to base relations that are functions */ Assert(rel->relid > 0); - Assert(rel->rtekind == RTE_FUNCTION); + rte = rt_fetch(rel->relid, root->parse->rtable); + Assert(rte->rtekind == RTE_FUNCTION); /* * Estimate number of rows the function itself will return. * - * XXX no idea how to do this yet; but should at least check whether + * XXX no idea how to do this yet; but we can at least check whether * function returns set or not... */ - rel->tuples = 1000; + if (expression_returns_set(rte->funcexpr)) + rel->tuples = 1000; + else + rel->tuples = 1; /* Now estimate number of output rows, etc */ set_baserel_size_estimates(root, rel);