Gavin Wahl <gavinwahl(at)gmail(dot)com> writes:
> It'd be nice if the planner could optimize the query (1) by turning it
> into (2). I understand that it might not be able to, but if it can pull
> the condition up in (3), why can't it in (4)?
(3) is an instance of seeing "a = b and b = c" and deducing "a = c" from
that. (4) does not follow that pattern, so it's outside the realm of
what the planner can deduce.
In principle we could take "a = b and (b = c or b = d)" and deduce
"a = c or a = d" from that, but it'd be a lot more complication for a
lot less benefit than what we get from the existing logic.
regards, tom lane