Re: How slow is distinct - 2nd - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: How slow is distinct - 2nd
Date
Msg-id 20021004153108.GA14180@wolff.to
Whole thread Raw
In response to How slow is distinct - 2nd  ("Michael Contzen" <Michael.Contzen@dohle.com>)
List pgsql-sql
On Tue, Oct 01, 2002 at 14:18:50 +0200, Michael Contzen <Michael.Contzen@dohle.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.


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: How slow is distinct - 2nd
Next
From: Oleg Bartunov
Date:
Subject: Re: rows in order