Re: How slow is distinct - 2nd

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Michael Contzen <Michael(dot)Contzen(at)dohle(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How slow is distinct - 2nd
Date: 2002-10-04 15:31:08
Message-ID: 20021004153108.GA14180@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-10-04 15:34:44 Re: Can Postgres cache a table in memory?
Previous Message Oleg Bartunov 2002-10-04 15:05:55 Re: rows in order