Re: DISTINCT -> GROUP BY

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "David Fetter" <david(at)fetter(dot)org>
Cc: "PG Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: DISTINCT -> GROUP BY
Date: 2008-06-03 13:36:44
Message-ID: 162867790806030636p17d6f9b4g8f65f3ed42dbf969@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello David

http://www.postgresql.org/docs/faqs.TODO.html

Consider using hash buckets to do DISTINCT, rather than sorting
This would be beneficial when there are few distinct values. This is
already used by GROUP BY.

Regards
Pavel Stehule

2008/6/3 David Fetter <david(at)fetter(dot)org>:
> Folks,
>
> I've noticed that queries of the form
>
> SELECT DISTNCT foo, bar, baz
> FROM quux
> WHERE ...
>
> perform significantly worse than the equivalent using GROUP BY.
>
> SELECT foo, bar, baz
> FROM quux
> WHERE ...
> GROUP BY foo, bar, baz
>
> Where would I start looking in order to make them actually equivalent
> from the planner's point of view? Also, would back-patching this make
> sense? It doesn't change any APIs, but it does make some queries go
> faster.
>
> Cheers,
> David.
> --
> David Fetter <david(at)fetter(dot)org> http://fetter.org/
> Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
> Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
>
> Remember to vote!
> Consider donating to Postgres: http://www.postgresql.org/about/donate
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2008-06-03 14:03:06 Re: DISTINCT -> GROUP BY
Previous Message David Fetter 2008-06-03 13:03:42 DISTINCT -> GROUP BY