aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-10-05 17:19:19 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-10-05 17:19:19 +0000
commite01145902973881c61acb6b54187128bab9c645b (patch)
tree5b18afe685c6e0c7aaa892d306ba5f8a60acefcc /src/backend
parent93d358a8a4442358c3edccf53014d8a2e65a5bbe (diff)
downloadpostgresql-e01145902973881c61acb6b54187128bab9c645b.tar.gz
postgresql-e01145902973881c61acb6b54187128bab9c645b.zip
Make set_function_size_estimates() marginally smarter: per original
comment, it can at least test whether the expression returns set.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/optimizer/path/costsize.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index 24af7afe799..bb506678ce4 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -49,7 +49,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.147 2005/08/27 22:37:00 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.148 2005/10/05 17:19:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -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);