Robert Creager <Robert_Creager@LogicalChaos.org> writes:
> What I had thought is that PG would (could?) be smart enough to realize tha=
> t one query was restricted, and apply that restriction to the other based o=
> n the join. I know it works in other cases (using indexes on both tables u=
> sing the join)...
The planner understands about transitivity of equality, ie given a = b
and b = c it can infer a = c. It doesn't do any such thing for
inequalities though, nor does it deduce f(a) = f(b) for arbitrary
functions f. The addition Michael suggested requires much more
understanding of the properties of the functions in your query than
I think would be reasonable to put into the planner.
regards, tom lane