Thomas Hamilton wrote:
> When run against a large dataset with a small number of distinct results
> HashAggregate is an order of magnitude more efficient!
>
> Since the spec does not require DISTINCT to return sorted results, I don't
> believe Sort ... Unique will ever be more efficient than HashAggregate.
This is not a bug -- merely a missing optimizer feature, which as it
turns out was implemented in 8.4.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.