Chris Shoemaker <chris.shoemaker@cox.net> writes:
> Still stumped,
The short answer here is that the planner is guessing that scanning the
index in ID order will come across the desired row (ie, the first one
matching the join condition) in less time than it will take to select
all the joinable rows, sort them by ID, and take the first one. It's
wrong in this case, but the plan is not unreasonable on its face.
The problem boils down to a misestimate of how many join rows there are.
You might get better results by increasing the statistics targets.
There are plenty of similar cases in the list archives.
regards, tom lane