Re: Allow WindowFuncs prosupport function to use more optimal WindowClause options

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Vik Fearing <vik(at)postgresfriends(dot)org>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Erwin Brandstetter <brsaweda(at)gmail(dot)com>
Subject: Re: Allow WindowFuncs prosupport function to use more optimal WindowClause options
Date: 2022-12-22 23:47:24
Message-ID: CAApHDvrkLLWt6SYQChPy+PJj_9UxV+KRWas1yzaKH9aTF0V=Uw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 26 Oct 2022 at 14:38, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Sun, 23 Oct 2022 at 03:03, Vik Fearing <vik(at)postgresfriends(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Imseih (AWS), Sami 2022-12-23 00:05:11 Re: Call lazy_check_wraparound_failsafe earlier for parallel vacuum
Previous Message Ranier Vilela 2022-12-22 22:20:26 Re: ARRNELEMS Out-of-bounds possible errors