"Kevin Grittner" <Kevin.Grittner@xxxxxxxxxxxx> writes: > Since you were so confident it couldn't be the outer join, I went > looking for what else I changed at the same time. I eliminated the code > referencing that table, which contained an OR. I've seen ORs cause > nasty problems with optimizers in the past. I took out the OR in the > where clause, without eliminating that last outer join, and it optimized > fine. I don't think that OR is relevant either, since again it's present in both the well-optimized and badly-optimized variants that you posted. regards, tom lane