Re: pgsql: Fix LATERAL join test in test memoize.sql - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Fix LATERAL join test in test memoize.sql
Date
Msg-id 2149153.1674519788@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Fix LATERAL join test in test memoize.sql  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-committers
David Rowley <dgrowleyml@gmail.com> writes:
> You're right that OFFSET 0 would have been a better choice. I just
> wasn't aware that we were considering changing the code so we pull up
> subqueries with an ORDER BY.

No such plan is in the offing AFAIK, but it doesn't seem entirely
out of the question either.

> In fact, I thought there were several
> good reasons we're not doing that. e.g. allow aggregation in outer
> query by some order specified by the subquery. But perhaps any changes
> we make in this area would be more conditional than just ignoring the
> fact that the subquery has an ORDER BY.

Yeah, we've historically honored subquery ORDER BY and I doubt we'd
want to stop.  But I'm not sure that that that completely precludes
subquery flattening, especially for single-relation subqueries such
as these.  You could imagine, for example, still doing the pull-up
and then only accepting paths for the rel that satisfy the ORDER BY.
This could still lead to better optimization of the outer query
than what happens now, I think.

Anyway, it's not something I expect to happen soon, but maybe
someday.

            regards, tom lane



pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: Re: pgsql: Fix LATERAL join test in test memoize.sql
Next
From: David Rowley
Date:
Subject: pgsql: Use OFFSET 0 instead of ORDER BY to stop subquery pullup