Re: A performance issue in ROW_NUMBER() OVER(ORDER BY NULL) [27 times slow than OVER()] V14.5

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kirk Wolak <wolakk(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: A performance issue in ROW_NUMBER() OVER(ORDER BY NULL) [27 times slow than OVER()] V14.5
Date: 2023-02-19 21:18:07
Message-ID: 3330162.1676841487@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kirk Wolak <wolakk(at)gmail(dot)com> writes:
> I have some converted code that uses this syntax.

Seems kinda dumb, but ...

> The solution is to remove the ORDER BY NULL. [since that is not
> sortable, should it be ignored?]
> This does NOT SHOW UP with 1 million rows.

I don't see it at all. Comparing your two test queries on released
branches, I see maybe 2x penalty for the ORDER BY NULL, not 30x.
(In HEAD there's only about 13% penalty.) I wonder what PG version
you are testing.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Rowley 2023-02-19 23:26:17 Re: A performance issue in ROW_NUMBER() OVER(ORDER BY NULL) [27 times slow than OVER()] V14.5
Previous Message Kirk Wolak 2023-02-19 19:43:16 A performance issue in ROW_NUMBER() OVER(ORDER BY NULL) [27 times slow than OVER()] V14.5