Re: Inlining functions with "expensive" parameters

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Paul Ramsey <pramsey(at)cleverelephant(dot)ca>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Inlining functions with "expensive" parameters
Date: 2017-11-16 19:44:52
Message-ID: 6480.1510861492@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> 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 of thought we only worried about that if the parameter
was referenced more than once, but I might be wrong.

> But what I *am* wondering about, is why we're not handling the
> parameters in a different way. Instead of replacing the all parameter
> references with the parameter, it shouldn't be too hard to instead
> replace them with a new PARAM_EXEC like Param.

Yeah, there's no mechanism like that now, but there could be. I wonder
if we could connect that to the work that was being done for caching
nonvolatile subexpressions --- it feels like much the same problem.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-11-16 19:51:55 Re: Inlining functions with "expensive" parameters
Previous Message Andres Freund 2017-11-16 19:41:35 Re: [HACKERS] Issues with logical replication