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: Mon, 20 Feb 2023 09:58:49 -0500
Message-ID: <3565866.1676905129@sss.pgh.pa.us> (raw)
In-Reply-To: <CAApHDvpPdBTYBmR4yxpphNkP+ULmzPAOfqzf0=QUTycDtP7Bhg@mail.gmail.com>
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>
<CAApHDvpPdBTYBmR4yxpphNkP+ULmzPAOfqzf0=QUTycDtP7Bhg@mail.gmail.com>
David Rowley <dgrowleyml@gmail.com> writes:
> On Mon, 20 Feb 2023 at 13:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> 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.
> I wonder what the comment had in mind when it said it doesn't seem
> worth it. Doing an if (IsA(tle->expr, Const)) continue; seems pretty
> simple and low-cost.
The right way to do this would be to pass forward information
about which window sort columns had been deemed redundant during
make_pathkeys_for_sortclauses: there are a lot more ways for that
to happen than "it's a constant".
The recent addition of make_pathkeys_for_sortclauses_extended would
make it pretty easy for make_pathkeys_for_window to obtain a reduced list
of SortGroupClauses, and then in theory you could match that against the
original lists to identify which sort columns are redundant (though
repeated keys might make that tricky; might be better to provide another
more-direct output representation). Pass the information forward in
WindowAggPath, et voila.
I remain doubtful that it's worth the trouble though.
> I've not looked at what the comment mentions
> about RANGE OFFSET. Assuming we'd need to not remove any ORDER BY
> clauses when the WindowClause is doing that.
There's some Asserts in nodeWindowAgg.c about ordNumCols being
positive, probably related.
regards, tom lane
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: <3565866.1676905129@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> <CAApHDvpPdBTYBmR4yxpphNkP+ULmzPAOfqzf0=QUTycDtP7Bhg@mail.gmail.com> <3565866.1676905129@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