Robert Haas <robertmhaas@gmail.com> writes:
> I'm not quite sure, either. I think that the first option (proving
> that there can be no NULL values) is probably more similar to
> thingswe've done elsewhere in the planner, so I think I have been
> assuming that if we did something about this, it would be that.
Yeah. The key problem blocking doing something about it in the
planner is that at the time we want to do join tree restructuring,
we haven't yet collected the per-relation data that would allow
us to know about NOT NULL constraints, nor run expression
simplification that would be important for detecting all but the
most basic cases. Doing either of those things twice seems like
a nonstarter from a planner-speed viewpoint. It's possible that
we could rearrange things to collect catalog data sooner.
(I'm vaguely imagining that we'd collect that stuff by relation
OID to begin with, and then when we build RelOptInfos later on
we could link to the per-rel-OID catalog data.) Moving expression
simplification up seems considerably more fraught, but maybe we could
handle the cases of common interest without having done that.
regards, tom lane