Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Can we try to pull up direct-correlated ANY SubLink with the help of
> > LATERAL?
>
> Perhaps. But what's the argument that you'd end up with a better
> plan? LATERAL pretty much constrains things to use a nestloop,
> so I'm not sure there's anything fundamentally different.
I think that subquery pull-up is most beneficial when the queries (both the
subquery and the upper query) contain more than a few tables. In such a case,
if only a few tables reference the upper query (or if just a single one does),
the constraints imposed by LATERAL might be less significant.
Nevertheless, I don't know how to overcome the problems that I mentioned
upthread.
--
Antonin Houska
Web: https://www.cybertec-postgresql.com