On Tue, Oct 01, 2002 at 14:18:50 +0200,
Michael Contzen <Michael(dot)Contzen(at)dohle(dot)com> wrote:
> Here the table:
>
> mc=# \d egal
> Table "public.egal"
> Column | Type | Modifiers
> --------+---------+-----------
> i | integer |
>
> mc=# select count(*) from egal;
> count
> ---------
> 7227744
> (1 row)
>
> mc=# select count(distinct i) from egal;
> count
> -------
> 67
> (1 row)
This suggests that the best way to do this is with a hash instead of a sort.
If you have lots of memory you might try increasing the sort memory size.