Thread: Re: [COMMITTERS] pgsql: Invent a "one-shot" variant of CachedPlans for better performanc

On 4 January 2013 22:42, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Invent a "one-shot" variant of CachedPlans for better performance.
...
> Back-patch to 9.2, since this was a performance regression compared to 9.1.
> (In 9.2, place the added struct fields so as to avoid changing the offsets
> of existing fields.)
>
> Heikki Linnakangas and Tom Lane

Just a moment of reflection here but I did already invent a "one-shot"
plan concept in a patch submission to 9.2, called exactly that, which
enables a variety of optimizations, this being one.

It's a shame that my patch was deferred in favour of your approach,
yet it never happened until now, well after release. Given that I
raised this before the first CF of 9.2, that is not good.

We need a full "one-shot" concept linking the planner and executor for
all sorts of reasons, not just this one. We can discuss the
practicality of individual optimizations but the linkage should be
clear throughout the whole infrastructure.

-- Simon Riggs                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



Simon Riggs <simon@2ndquadrant.com> writes:
> On 4 January 2013 22:42, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Invent a "one-shot" variant of CachedPlans for better performance.

> Just a moment of reflection here but I did already invent a "one-shot"
> plan concept in a patch submission to 9.2, called exactly that, which
> enables a variety of optimizations, this being one.

If you're speaking of
http://archives.postgresql.org/pgsql-hackers/2011-06/msg01168.php

that patch was vastly more invasive than this one, with vastly less
clear performance characteristics (none of which were documented by test
cases).  And it had the potential for unexpected user-visible semantics
changes; for instance, as submitted it made EXPLAIN produce results
different from what might actually happen at execution.  I don't think
there's any comparison to this patch at all except in the nomenclature.

> We need a full "one-shot" concept linking the planner and executor for
> all sorts of reasons, not just this one. We can discuss the
> practicality of individual optimizations but the linkage should be
> clear throughout the whole infrastructure.

I thought then, and I think now, that such a concept was too squishy
to be useful as an actual guide to what to change.  The particular
arguments you advanced then have been overtaken by events anyway;
notably that Marti Raudsepp's work on caching stable subexpressions at
execution seems like a much more general answer to the problem of
handling stable functions efficiently.
        regards, tom lane



On 5 January 2013 19:15, Tom Lane <tgl@sss.pgh.pa.us> wrote:

>> We need a full "one-shot" concept linking the planner and executor for
>> all sorts of reasons, not just this one. We can discuss the
>> practicality of individual optimizations but the linkage should be
>> clear throughout the whole infrastructure.
>
> I thought then, and I think now, that such a concept was too squishy
> to be useful as an actual guide to what to change.  The particular
> arguments you advanced then have been overtaken by events anyway;
> notably that Marti Raudsepp's work on caching stable subexpressions at
> execution seems like a much more general answer to the problem of
> handling stable functions efficiently.

I knew, and accepted that that specific optimization has been
superceded. My point is that the "one-shot" situation lends itself to
a great many optimizations and if we can pass that concept through, we
can simply get on with implementing them.

Having the planner pretend that it doesn't know what will happen at
execution time isn't sensible. Having the executor know its a one-off
will surely help somewhere along the line. It's hardly a modularity
violation to pass small, yet major pieces of information across the
divide.

-- Simon Riggs                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services