Re: Inlining functions with "expensive" parameters

2017-11-21 Thread Andres Freund
Hi, On 2017-11-21 10:16:58 -0500, Tom Lane wrote: > I'm also wondering about folding CaseTestExpr and CoerceToDomainValue > into the same mechanism. It's not very hard to see those cases as > being the same as a function-based lambda. Yea, that'd be good. The current mechanisms is uh, historical

Re: Inlining functions with "expensive" parameters

2017-11-21 Thread Andres Freund
On 2017-11-21 09:59:00 -0500, Robert Haas wrote: > On Thu, Nov 16, 2017 at 2:51 PM, Andres Freund wrote: > > Right, but it doesn't sound that hard to introduce. Basically there'd need > > to be a WithParamValue node, that first evaluates parameters and then > > executes the child expression. I'

Re: Inlining functions with "expensive" parameters

2017-11-21 Thread Tom Lane
I wrote: > Robert Haas writes: >> I don't quite follow the need for this. I mean, if we just stick a >> Param reference in there and create a corresponding InitPlan, the >> Param will be evaluated on demand, right? Is the point of the new >> node to make sure that the Param gets re-evaluated whe

Re: Inlining functions with "expensive" parameters

2017-11-21 Thread Tom Lane
Robert Haas writes: > On Thu, Nov 16, 2017 at 2:51 PM, Andres Freund wrote: >> Right, but it doesn't sound that hard to introduce. Basically there'd >> need to be a WithParamValue node, that first evaluates parameters and >> then executes the child expression. > I don't quite follow the need fo

Re: Inlining functions with "expensive" parameters

2017-11-21 Thread Robert Haas
On Thu, Nov 16, 2017 at 2:51 PM, Andres Freund wrote: > Right, but it doesn't sound that hard to introduce. Basically there'd need to > be a WithParamValue node, that first evaluates parameters and then executes > the child expression. I'm thinking of doing this hierarchically so there's > les

Re: Inlining functions with "expensive" parameters

2017-11-17 Thread Andres Freund
On November 17, 2017 5:15:57 AM PST, Paul Ramsey wrote: >On Thu, Nov 16, 2017 at 12:37 PM, Andres Freund >wrote: > >> Hi, >> >> On 2017-11-16 15:27:59 -0500, Tom Lane wrote: >> > Andres Freund writes: >> > > On November 16, 2017 11:44:52 AM PST, Tom Lane > >> wrote: >> > >> Yeah, there's no m

Re: Inlining functions with "expensive" parameters

2017-11-17 Thread Paul Ramsey
On Thu, Nov 16, 2017 at 12:37 PM, Andres Freund wrote: > Hi, > > On 2017-11-16 15:27:59 -0500, Tom Lane wrote: > > Andres Freund writes: > > > On November 16, 2017 11:44:52 AM PST, Tom Lane > wrote: > > >> Yeah, there's no mechanism like that now, but there could be. > > > > > Right, but it doe

Re: Inlining functions with "expensive" parameters

2017-11-16 Thread Andres Freund
Hi, On 2017-11-16 15:27:59 -0500, Tom Lane wrote: > Andres Freund writes: > > On November 16, 2017 11:44:52 AM PST, Tom Lane wrote: > >> Yeah, there's no mechanism like that now, but there could be. > > > Right, but it doesn't sound that hard to introduce. Basically there'd need > > to be a Wi

Re: Inlining functions with "expensive" parameters

2017-11-16 Thread Tom Lane
Andres Freund writes: > On November 16, 2017 11:44:52 AM PST, Tom Lane wrote: >> Yeah, there's no mechanism like that now, but there could be. > Right, but it doesn't sound that hard to introduce. Basically there'd need to > be a WithParamValue node, that first evaluates parameters and then ex

Re: Inlining functions with "expensive" parameters

2017-11-16 Thread Andres Freund
On November 16, 2017 11:44:52 AM PST, Tom Lane wrote: >Andres Freund writes: >> Well, it's not a question of cost of the function now? Imagine >> SELECT inlineable(something()); >> if you have 10 references for the parameter inside inlineable(). Then >> currently something() would be evalua

Re: Inlining functions with "expensive" parameters

2017-11-16 Thread Tom Lane
Andres Freund writes: > Well, it's not a question of cost of the function now? Imagine > SELECT inlineable(something()); > if you have 10 references for the parameter inside inlineable(). Then > currently something() would be evaluated 10 times. Which'd quite > possibly be bad. Right. I kind

Re: Inlining functions with "expensive" parameters

2017-11-16 Thread Andres Freund
Hi, On 2017-11-16 09:37:29 -0800, Paul Ramsey wrote: > On Thu, Nov 9, 2017 at 12:11 PM, Paul Ramsey > wrote: > > > All, > > > > As we try and make PostGIS more "parallel sensitive" we have been added > > costs to our functions, so that their relative CPU cost is more accurately > > reflected in

Re: Inlining functions with "expensive" parameters

2017-11-16 Thread Paul Ramsey
On Thu, Nov 9, 2017 at 12:11 PM, Paul Ramsey wrote: > All, > > As we try and make PostGIS more "parallel sensitive" we have been added > costs to our functions, so that their relative CPU cost is more accurately > reflected in parallel plans. > > This has resulted in an odd side effect: some of o