DISTINCT -> GROUP BY - Mailing list pgsql-hackers

From David Fetter
Subject DISTINCT -> GROUP BY
Date
Msg-id 20080603130342.GC22141@fetter.org
Whole thread Raw
Responses Re: DISTINCT -> GROUP BY  ("Pavel Stehule" <pavel.stehule@gmail.com>)
List pgsql-hackers
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@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


pgsql-hackers by date:

Previous
From: Paul van den Bogaard
Date:
Subject: Re: Overhauling GUCS
Next
From: "Pavel Stehule"
Date:
Subject: Re: DISTINCT -> GROUP BY