Re: Unfortunate pushing down of expressions below sort

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org, David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Re: Unfortunate pushing down of expressions below sort
Date: 2026-02-06 00:13:09
Message-ID: 1668738.1770336789@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> writes:
> We push down expressions below a sort node, even though they could be
> evaluated above.

Yeah. That's a hangover from an ancient decision that sort/limit
would always be applied at the top of the plan tree. I'm too
lazy to check the details right now, but I think we already relaxed
that in some cases (or maybe it was about evaluating stuff
before/after GROUP BY?).

> That can very substantially increase the space needed for the
> sort.

Could decrease it too, eg if what you are outputting is
md5(some-wide-column). Not sure we are smart enough to tell
which way is better.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2026-02-06 00:18:50 Re: client_connection_check_interval default value
Previous Message Tom Lane 2026-02-06 00:01:52 Re: client_connection_check_interval default value