Re: Optimize common expressions in projection evaluation - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Optimize common expressions in projection evaluation
Date
Msg-id 3102800.1670215673@sss.pgh.pa.us
Whole thread Raw
In response to Re: Optimize common expressions in projection evaluation  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> po 5. 12. 2022 v 5:28 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
>> I tend to agree with David that LATERAL offers a good-enough
>> solution in most cases ... but it is annoying that we accept
>> this syntax and then pessimize it.

> I agree, so there is a perfect solution like don't use .*, but on second
> hand any supported syntax should be optimized well or we should raise some
> warning about negative performance impact.

Yeah.  I wonder if we could get the parser to automatically transform

    SELECT (foo(t.x)).* FROM tab t

into

    SELECT f.* FROM tab t, LATERAL foo(t.x) f

There are probably cases where this doesn't work or changes the
semantics subtly, but I suspect it could be made to work in
most cases of practical interest.

            regards, tom lane



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Bug in row_number() optimization
Next
From: "David G. Johnston"
Date:
Subject: Re: Optimize common expressions in projection evaluation