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