Re: pgsql: Fix LATERAL join test in test memoize.sql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org, Richard Guo <guofenglinux(at)gmail(dot)com>
Subject: Re: pgsql: Fix LATERAL join test in test memoize.sql
Date: 2023-01-24 00:23:08
Message-ID: 2149153.1674519788@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

David Rowley <dgrowleyml(at)gmail(dot)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

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2023-01-24 00:49:31 pgsql: Use OFFSET 0 instead of ORDER BY to stop subquery pullup
Previous Message David Rowley 2023-01-24 00:08:01 Re: pgsql: Fix LATERAL join test in test memoize.sql