Skip to content

Commit e011459

Browse files
committed
Make set_function_size_estimates() marginally smarter: per original
comment, it can at least test whether the expression returns set.
1 parent 93d358a commit e011459

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/backend/optimizer/path/costsize.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* Portions Copyright (c) 1994, Regents of the University of California
5050
*
5151
* IDENTIFICATION
52-
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.147 2005/08/27 22:37:00 tgl Exp $
52+
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.148 2005/10/05 17:19:19 tgl Exp $
5353
*
5454
*-------------------------------------------------------------------------
5555
*/
@@ -1898,17 +1898,23 @@ join_in_selectivity(JoinPath *path, PlannerInfo *root)
18981898
void
18991899
set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel)
19001900
{
1901+
RangeTblEntry *rte;
1902+
19011903
/* Should only be applied to base relations that are functions */
19021904
Assert(rel->relid > 0);
1903-
Assert(rel->rtekind == RTE_FUNCTION);
1905+
rte = rt_fetch(rel->relid, root->parse->rtable);
1906+
Assert(rte->rtekind == RTE_FUNCTION);
19041907

19051908
/*
19061909
* Estimate number of rows the function itself will return.
19071910
*
1908-
* XXX no idea how to do this yet; but should at least check whether
1911+
* XXX no idea how to do this yet; but we can at least check whether
19091912
* function returns set or not...
19101913
*/
1911-
rel->tuples = 1000;
1914+
if (expression_returns_set(rte->funcexpr))
1915+
rel->tuples = 1000;
1916+
else
1917+
rel->tuples = 1;
19121918

19131919
/* Now estimate number of output rows, etc */
19141920
set_baserel_size_estimates(root, rel);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy