pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Kirk Wolak <wolakk@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: A performance issue in ROW_NUMBER() OVER(ORDER BY NULL) [27 times slow than OVER()] V14.5
Date: Sun, 19 Feb 2023 19:17:45 -0500
Message-ID: <3452823.1676852265@sss.pgh.pa.us> (raw)
In-Reply-To: <CAApHDvqSR_ZQ50Q2cGicw51QhK6UJ6YwiTyw8y3XpNw_4jRBLA@mail.gmail.com>
References: <CACLU5mS7Wc=xANexj7KSPMX2PRnv6FwDDHQn2DW+MY1UDBJm3A@mail.gmail.com>
	<3330162.1676841487@sss.pgh.pa.us>
	<CAApHDvqSR_ZQ50Q2cGicw51QhK6UJ6YwiTyw8y3XpNw_4jRBLA@mail.gmail.com>

David Rowley <dgrowleyml@gmail.com> writes:
> I suspect ed1a88dda would be what made this faster in master. We'll
> check for peer rows to check "NULL IS NOT DISTINCT FROM NULL" prior to
> that change with the ORDER BY NULL query.

Mmm, yeah, probably so: "order by null rows between unbounded preceding
and current row" has about the same performance in v15 as HEAD has
with just "order by null".

I suspect most of the remaining performance discrepancy is just triggered
by having to pass the extra always-NULL column forward through the various
plan steps.  We could teach createplan.c to generate a WindowAgg plan node
that omits the useless column from ordNumCols/ordColIdx/etc, but I'm not
sure if that'd save much in itself.  (The comment in create_windowagg_plan
shows we already thought about that and decided it wasn't worth the
trouble.)  Getting rid of the useless targetlist column altogether would
be way more invasive, and I'm not inclined to try.

			regards, tom lane





view thread (8+ messages)  latest in thread

Message-ID: <3452823.1676852265@sss.pgh.pa.us>
Permalink:  ../3452823.1676852265@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3452823.1676852265@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, wolakk@gmail.com
  Subject: Re: A performance issue in ROW_NUMBER() OVER(ORDER BY NULL) [27 times slow than OVER()] V14.5
  In-Reply-To: <3452823.1676852265@sss.pgh.pa.us>
  References: <CACLU5mS7Wc=xANexj7KSPMX2PRnv6FwDDHQn2DW+MY1UDBJm3A@mail.gmail.com> <3330162.1676841487@sss.pgh.pa.us> <CAApHDvqSR_ZQ50Q2cGicw51QhK6UJ6YwiTyw8y3XpNw_4jRBLA@mail.gmail.com> <3452823.1676852265@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox