RE: New Window Function: ROW_NUMBER_DESC() OVER() ?

From: Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>
To: David Rowley <dgrowleyml(at)gmail(dot)com>, Michał Kłeczek <michal(at)kleczek(dot)org>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: New Window Function: ROW_NUMBER_DESC() OVER() ?
Date: 2024-01-17 02:28:09
Message-ID: CP4P284MB2483032E6B4B5A10DE5EC731EC722@CP4P284MB2483.BRAP284.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

As far as I see your proposal, you want to allow something that is
undefined to be reversed. I don't think this is a good idea at all.
As mentioned by others, you should have ORDER BY clauses and just add
a DESC.

* Okay, now I'm convinced of that.

If you were looking for something to optimize in this rough area, then
perhaps adding some kind of "Backward WindowAgg" node (by overloading
the existing node) to allow queries such as the following to be
executed without an additional sort.

SELECT a,row_number() over (order by a desc) from t order by a;

* David, considering this optimization, allowing for that, do you believe it is plausible to try advancing towards a possible Proof of Concept (PoC) implementation?

Maiquel.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2024-01-17 02:30:00 Re: introduce dynamic shared memory registry
Previous Message Jelte Fennema-Nio 2024-01-17 02:21:26 Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs