Re: Window Function "Run Conditions" - Mailing list pgsql-hackers

From Andy Fan
Subject Re: Window Function "Run Conditions"
Date
Msg-id CAKU4AWq5MB_inrYUwPQYXU1fCopCwgYK53N2uYGYFBH3QEhZMA@mail.gmail.com
Whole thread Raw
In response to Re: Window Function "Run Conditions"  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Window Function "Run Conditions"  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
Hi David:

Thanks for the patch.

On Wed, Aug 18, 2021 at 6:40 PM David Rowley <dgrowleyml@gmail.com> wrote:
>
> On Tue, 17 Aug 2021 at 03:51, Zhihong Yu <zyu@yugabyte.com> wrote:
> > +               if ((res->monotonic & MONOTONICFUNC_INCREASING) == MONOTONICFUNC_INCREASING)
> >
> > The above can be simplified as 'if (res->monotonic & MONOTONICFUNC_INCREASING) '
>
> True.  I've attached an updated patch.
>
> David

Looks like we need to narrow down the situation where we can apply
this optimization.

SELECT * FROM
  (SELECT empno,
          salary,
                  count(*) over (order by empno desc) as c      ,
          dense_rank() OVER (ORDER BY salary DESC) dr

   FROM empsalary) emp
WHERE dr = 1;

In the current master, the result is:

 empno | salary | c | dr

-------+--------+---+----

     8 |   6000 | 4 |  1

(1 row)

In the patched version, the result is:

 empno | salary | c | dr

-------+--------+---+----

     8 |   6000 | 1 |  1

(1 row)

--
Best Regards
Andy Fan (https://www.aliyun.com/)



pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: NAMEDATALEN increase because of non-latin languages
Next
From: Hannu Krosing
Date:
Subject: pgbench functions as extension