DISTINCT vs. GROUP BY

Поиск
Список
Период
Сортировка
От Hans-Jürgen Schönig
Тема DISTINCT vs. GROUP BY
Дата
Msg-id 432ECAE2.7070805@cybertec.at
обсуждение исходный текст
Ответы Re: DISTINCT vs. GROUP BY  (Neil Conway <neilc@samurai.com>)
Re: DISTINCT vs. GROUP BY  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I was wondering whether it is possible to teach the planner to handle 
DISTINCT in a more efficient way:

em=# explain select distinct lastname from import.testtest;                                   QUERY PLAN
-------------------------------------------------------------------------------- Unique  (cost=2647377.45..2709467.70
rows=1width=7)   ->  Sort  (cost=2647377.45..2678422.58 rows=12418051 width=7)         Sort Key: lastname         ->
SeqScan on testtest  (cost=0.00..370082.51 rows=12418051 
 
width=7)
(4 Zeilen)


Isn't it possible to perform the same operation using a HashAggregate?
We have seen that a GROUP BY workaround is usually a lot faster than 
sort->unique - at least when work_mem is large enough.
best regards,
    hans


-- 
Cybertec Geschwinde & Schönig GmbH
Schöngrabern 134; A-2020 Hollabrunn
Tel: +43/1/205 10 35 / 340
www.postgresql.at, www.cybertec.at


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

Предыдущее
От: Devrim GUNDUZ
Дата:
Сообщение: Re: New dot releases
Следующее
От: Neil Conway
Дата:
Сообщение: Re: DISTINCT vs. GROUP BY