pilum.70@uni-muenster.de writes:
> The following query uses bitmap or index scan in 9.1, but only Nested Loop
> in 9.2 and 9.3:
Interesting. The plan actually gets stupider when it has values for the
parameters, if those values chance to be NULL.
The reason seems to be that after substituting the parameters and
constant-folding, we've got this join condition:
(t1.id2 = ''::text AND t2.id2 = ''::text) OR NULL::boolean
and the code in orclause.c is unable to realize that it can extract the
sub-AND elements as restriction clauses for t1 and t2. But it'd be
all right to ignore the constant-null OR arm, since that can't possibly
succeed.
Another way of looking at this is that we should be smart enough to throw
away the constant-null OR arm altogether at top level of WHERE, since at
top level we don't particularly care whether the OR produces FALSE or NULL
if all its other inputs are FALSE. That would probably be a more general
fix.
I'll see what I can do about this. Thanks for the report!
regards, tom lane