Nick Howden <n.howden@eris.qinetiq.com> writes:
> Using postgres 7.2.3 the query planner seems to lose interest in using
> indexes when DISTINCT is used.
I don't think this is a bug. DISTINCT requires a sort step, so even
though you have a LIMIT, the planner has to plan on the basis of reading
the entire join table. The nestloop plan loses badly on that basis.
regards, tom lane