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

From: Vik Fearing <vik(at)postgresfriends(dot)org>
To: David Rowley <dgrowleyml(at)gmail(dot)com>, 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-10-12 03:33:33
Message-ID: 2c12c34b-8a71-888f-a6e2-757a03ba56f3@postgresfriends.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/12/22 04:40, David Rowley wrote:
> I've not really done any analysis into which other window functions
> can use this optimisation. The attached only adds support to
> row_number()'s support function and only converts exactly "RANGE
> UNBOUNDED PRECEDING AND CURRENT ROW" into "ROW UNBOUNDED PRECEDING AND
> CURRENT ROW". That might need to be relaxed a little, but I've done
> no analysis to find that out.

Per spec, the ROW_NUMBER() window function is not even allowed to have a
frame specified.

b) The window framing clause of WDX shall not be present.

Also, the specification for ROW_NUMBER() is:

f) ROW_NUMBER() OVER WNS is equivalent to the <window function>:

COUNT (*) OVER (WNS1 ROWS UNBOUNDED PRECEDING)

So I don't think we need to test for anything at all and can
indiscriminately add or replace the frame with ROWS UNBOUNDED PRECEDING.
--
Vik Fearing

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message kuroda.hayato@fujitsu.com 2022-10-12 04:01:21 RE: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
Previous Message Masahiko Sawada 2022-10-12 03:29:16 Re: test_decoding assertion failure for the loss of top-sub transaction relationship