Re: Possible bug in query planner when using DISTINCT - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Possible bug in query planner when using DISTINCT
Date
Msg-id 16982.1037301933@sss.pgh.pa.us
Whole thread Raw
In response to Possible bug in query planner when using DISTINCT  (Nick Howden <n.howden@eris.qinetiq.com>)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug #818: There are no aggregate functions for type RELTIME
Next
From: Theodore Petrosky
Date:
Subject: new journaling system in OSX