Re: group by will not use an index?

Поиск
Список
Период
Сортировка
Искать
От
Steinar H. Gunderson
Тема
Re: group by will not use an index?
Дата
Msg-id
20070110011104.GA21351@uio.no
Ответ на
Список
Дерево обсуждения
group by will not use an index? tsuraan <tsuraan@gmail.com>
Re: group by will not use an index? "Adam Rich" <adam.r@sbcglobal.net>
Re: group by will not use an index? Scott Marlowe <smarlowe@g2switchworks.com>
Re: group by will not use an index? Andrew Lazarus <andrew@pillette.com>
Re: group by will not use an index? tsuraan <tsuraan@gmail.com>
On Tue, Jan 09, 2007 at 05:07:03PM -0800, Brian Herlihy wrote:
> Actually, as I recently discovered, GROUP BY is faster than DISTINCT.  It's
> just due to how they are implemented, so don't go looking for any deep
> reason :)  The thread "GROUP BY vs DISTINCT" from 2006-12-20 discusses it.
> DISTINCT sorts the results to find the unique rows, but GROUP BY uses a
> hash.

Actually, GROUP BY _can_ use a sort too, it's just that a hash is usually
faster.

/* Steinar */
-- 
Homepage: http://www.sesse.net/
В списке pgsql-performance по дате отправления
От: Brian Herlihy
Дата:
От: Andrew Lazarus
Дата:
FAQ