> > This also brings up a line of thought I had a while ago on a related
> > topic. Something like a "HashDistinct" might be useful, if it had no
> > startup cost.
> We already have that: the planner will use a HashAgg node in this
> fashion in some contexts (I think just as one of the ways to
> We saw a case recently where a hash join was using much more memory than
> it was supposed to, causing failure when the server ran out of memory.
Yes. I had the same problem a few month ago,
http://archives.postgresql.org/pgsql-general/2004-09/msg00410.php
It turned out that the cost estimates