Re: Avoid extra Sort nodes between WindowAggs when sorting can be reused

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-07-02T21:19:16Z
Lists: pgsql-hackers

Attachments

> On 2 Jul 2018, at 14:01, Masahiko Sawada <sawada.mshk@gmail.com> wrote:

> Thank you for updating the patch! There are two review comments.

Thanks for reviewing!

> The current select_active_windows() function compares the all fields
> of WindowClause for the sorting but with this patch we compare only
> tleSortGroupRef, sortop and the number of uniqueOrder. I think this
> leads a degradation as follows.

You are right, that was an oversight.  The attached patch takes a stab at
fixing this.

> s/readibility/readability/

Fixed.

cheers ./daniel

Commits

  1. Order active window clauses for greater reuse of Sort nodes.