Re: Allow WindowFuncs prosupport function to use more optimal WindowClause options - Mailing list pgsql-hackers

From David Rowley
Subject Re: Allow WindowFuncs prosupport function to use more optimal WindowClause options
Date
Msg-id CAApHDvrkLLWt6SYQChPy+PJj_9UxV+KRWas1yzaKH9aTF0V=Uw@mail.gmail.com
Whole thread Raw
In response to Re: Allow WindowFuncs prosupport function to use more optimal WindowClause options  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Allow WindowFuncs prosupport function to use more optimal WindowClause options  (Vik Fearing <vik@postgresfriends.org>)
List pgsql-hackers
On Wed, 26 Oct 2022 at 14:38, David Rowley <dgrowleyml@gmail.com> wrote:
>
> On Sun, 23 Oct 2022 at 03:03, Vik Fearing <vik@postgresfriends.org> wrote:
> > Shouldn't it be able to detect that these two windows are the same and
> > only do one WindowAgg pass?
> >
> >
> > explain (verbose, costs off)
> > select row_number() over w1,
> >         lag(amname) over w2
> > from pg_am
> > window w1 as (order by amname),
> >         w2 as (w1 rows unbounded preceding)
> > ;
>
> Good thinking. I think the patch should also optimise that case. It
> requires re-doing a similar de-duplication phase the same as what's
> done in transformWindowFuncCall().  I've added code to do that in the
> attached version.

I've spent a bit more time on this now and added a few extra
regression tests.  The previous version had nothing to test to ensure
that an aggregate function being used as a window function does not
have its frame options changed when it's sharing the same WindowClause
as a WindowFunc which can have the frame options changed.

I've now pushed the final result.  Thank you to everyone who provided
input on this.

David



pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: ARRNELEMS Out-of-bounds possible errors
Next
From: "Imseih (AWS), Sami"
Date:
Subject: Re: Call lazy_check_wraparound_failsafe earlier for parallel vacuum