Re: GROUP BY vs DISTINCT

Поиск
Список
Период
Сортировка
От Steinar H. Gunderson
Тема Re: GROUP BY vs DISTINCT
Дата
Msg-id 20061220105739.GB31739@uio.no
обсуждение исходный текст
Ответ на GROUP BY vs DISTINCT  (Brian Herlihy <btherl@yahoo.com.au>)
Ответы Re: GROUP BY vs DISTINCT  ("Peter Childs" <peterachilds@gmail.com>)
Список pgsql-performance
On Tue, Dec 19, 2006 at 11:19:39PM -0800, Brian Herlihy wrote:
> Actually, I think I answered my own question already.  But I want to
> confirm - Is the GROUP BY faster because it doesn't have to sort results,
> whereas DISTINCT must produce sorted results?  This wasn't clear to me from
> the documentation.  If it's true, then I could save considerable time by
> using GROUP BY where I have been using DISTINCT in the past.  Usually I
> simply want a count of the distinct values, and there is no need to sort
> for that.

You are right; at the moment, GROUP BY is more intelligent than DISTINCT,
even if they have to compare the same columns. This is, as always, something
that could be improved in a future release, TTBOMK.

/* Steinar */
--
Homepage: http://www.sesse.net/

В списке pgsql-performance по дате отправления:

Предыдущее
От: Ragnar
Дата:
Сообщение: Re: max_fsm_pages and check_points
Следующее
От: "Peter Childs"
Дата:
Сообщение: Re: GROUP BY vs DISTINCT