Re: Avoid extra Sort nodes between WindowAggs when sorting can bereused - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: Avoid extra Sort nodes between WindowAggs when sorting can bereused
Date
Msg-id 33B858BA-932E-4851-B2D7-589130F19ED1@yesql.se
Whole thread Raw
In response to Re: Avoid extra Sort nodes between WindowAggs when sorting can bereused  (Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>)
Responses Re: Avoid extra Sort nodes between WindowAggs when sorting can bereused  (Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>)
List pgsql-hackers
> On 27 Jul 2018, at 21:12, Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru> wrote:

> Thanks for the update.

Thank you for reviewing and hacking!

> On 07/25/2018 01:37 AM, Daniel Gustafsson wrote:
>>
>>> Hmm, this is missing the eqop fields of SortGroupClause. I haven't
>>> tested yet but does the similar degradation happen if two
>>> SortGroupCaluses have different eqop and the same other values?
>> I wasn’t able to construct a case showing this, but I also think you’re right.
>> Do you have an idea of a query that can trigger a regression?  The attached
>> patch adds a stab at this, but I’m not sure if it’s the right approach.
>
> To trigger that, in your test example you could order by empno::int8 for one window, and by empno::int2 for another.
Butdon't I think you have to compare eqop here, because if eqop differs, sortop will differ too. I removed the
comparisonfrom the patch. 

Right, that makes sense.

> I also clarified (I hope) the comments, and did the optimization I mentioned earlier: using array instead of list for
activeclauses. Please see the attached v6. 

Thanks, looks good.

> Otherwise I think the patch is good.

Cool, thanks for reviewing!

cheers ./daniel

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: negative bitmapset member not allowed Error with partitionpruning
Next
From: Alvaro Herrera
Date:
Subject: Re: FailedAssertion on partprune