Thomas Munro <thomas.mu...@enterprisedb.com> writes: > This looks like an invisible correlation problem.
Yeah --- the planner has no idea that the join rows satisfying newdata.* *= newdata2.* are likely to be exactly the ones not satisfying newdata.ctid <> newdata2.ctid. It's very accidental that we got a good plan before. I've not looked to see where this query is generated, but I wonder if we could make things better by dropping the LIMIT 1 and instead using an executor count parameter to stop early. regards, tom lane