Robert Haas <robertmhaas@gmail.com> writes:
> I've been turning this one over in my head. It seems to me that this
> is very similar to what we already do with inner index-scans, only
> generalized to joinrels.
Right.
> Currently, however, we only consider this possibility when the inner
> rel is NOT a joinrel. It seems like it might be possible to change
> this, but it doesn't look straightforward.
Well, it's straightforward enough in theory, it's just the exponential
growth in the number of join paths to consider that's a problem :-(.
I think what we'd need is a heuristic to limit the paths considered.
I think Andrew was suggesting that we not attempt to consider this
automatically, but only when the user writes the query in a way that
exposes it directly via LATERAL. While that goes against my normal
instincts for the planner, it isn't unreasonable as a first step.
regards, tom lane