Simon Riggs <simon@xxxxxxxxxxxxxxx> writes: > Basically the planner doesn't ever optimise for the possibility of the > never-executed case because even a single row returned would destroy > that assumption. It's worse than that: the outer subplan *does* return some rows. I suppose that all of them had NULLs in the join keys, which means that (since 8.1 or so) nodeMergejoin discards them as unmatchable. Had even one been non-NULL the expensive subplan would have been run. This seems like too much of a corner case to justify adding a lot of machinery for. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq