Re: function(contants) evaluated for every row - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: function(contants) evaluated for every row
Date
Msg-id 201103110032.p2B0WpZ04921@momjian.us
Whole thread Raw
In response to Re: function(contants) evaluated for every row  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: function(contants) evaluated for every row
List pgsql-hackers
Robert Haas wrote:
> 2010/11/25 pasman pasma?ski <pasman.p@gmail.com>:
> >>I've seen this as well be a performance issue, in particular with partitioned tables.
> >>Out of habit I now write functions that always cache the value of the function in
> >>a variable and use the variable in the actual query to avoid this particular "gotcha".
> >
> > subquery may be used to cache constants:
> >
> > SELECT a_date
> > ?FROM test
> > ?WHERE a_date=(SELECT current_date);
> >
> >
> > "Seq Scan on test1 ?(cost=0.01..10.76 rows=5 width=4)"
> > " ?Filter: (a_date = $0)"
> > " ?InitPlan 1 (returns $0)"
> > " ? ?-> ?Result ?(cost=0.00..0.01 rows=1 width=0)"
> 
> Interesting.  So we pull a subquery out and treat it as an initplan,
> but not a stable function?  Hmm...

I assume this is _not_ a TODO.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: patch: fix performance problems with repated decomprimation of varlena values in plpgsql
Next
From: Robert Haas
Date:
Subject: Re: function(contants) evaluated for every row