Greg Stark <gsstark(at)mit(dot)edu> writes:
> Is there some way to force the optimizer not to substitute the subquery in the
> where clause?
You could try tinkering with the rules for invoking subquery_push_qual
in src/backend/optimizer/path/allpaths.c. This might be a case that
would fall under the note there wondering if pushing down can ever
result in a worse plan. I'm not sure though that we can tell the
difference reliably...
regards, tom lane