Amit Langote <langote_amit...@lab.ntt.co.jp> writes: > On 2019/03/23 6:07, Tom Lane wrote: >> I also feel like you used a dartboard while deciding where to insert the >> call in query_planner(); dropping it into the middle of a sequence of >> equivalence-class-related operations seems quite random. Maybe we could >> delay that step all the way to just before make_one_rel, since the other >> stuff in between seems to only care about baserels? For example, >> it'd certainly be better if we could run remove_useless_joins before >> otherrel expansion, so that we needn't do otherrel expansion at all >> on a table that gets thrown away as being a useless join.
> create_lateral_join_info() expects otherrels to be present to propagate > the information it creates. Sure, but the actually-useful work in that function is just concerned with baserels. The only thing it does with otherrels is to propagate parents' lateral-ref info to children, which is a lot easier, cheaper, and more reliable if we let build_simple_rel do it. See the version of 0001 I just pushed. I'll look at 0003 and up tomorrow. regards, tom lane