Re: Inlining functions with "expensive" parameters

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org, 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-21 15:04:19
Message-ID: 2309.1511276659@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Thu, Nov 16, 2017 at 2:51 PM, Andres Freund <andres(at)anarazel(dot)de> 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 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 when needed?

Yeah. By default, an initplan is only going to be evaluated once per
query, not once per row. It's possible that you could set up Param
dependencies to force the correct semantics, but that would be more
complicated, and probably less performant, than introducing a new
expression node type. Also, I'm dubious that it could be made to work
at all for standalone expression evaluation; Param-driven re-evaluation
is only considered when running a plan tree.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-11-21 15:16:58 Re: Inlining functions with "expensive" parameters
Previous Message Robert Haas 2017-11-21 14:59:00 Re: Inlining functions with "expensive" parameters