Re: SELECT DISTINCT very slow - Mailing list pgsql-general

From Bill Moran
Subject Re: SELECT DISTINCT very slow
Date
Msg-id 20090709112521.ded0391e.wmoran@potentialtech.com
Whole thread Raw
In response to SELECT DISTINCT very slow  (Ben Harper <rogojin@gmail.com>)
List pgsql-general
In response to Ben Harper <rogojin@gmail.com>:
> Hi,
> Can anybody explain this:
>
> Records: 600,000
> Field Width: Approximately 20 UTF8 characters - type is VARCHAR(25)
> Field is Indexed.
>
> SELECT DISTINCT field FROM table;
>
> Takes about 6 seconds. There are 111 distinct items.

What's the output of EXPLAIN ANALYZE SELECT DISTINCT field FROM table;?

Does a VACUUM ANALYZE of the table help?  Is the query significantly
faster the second time you run it?

> Is this a well known issue?

Not that I'm aware of.

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

pgsql-general by date:

Previous
From: Ms swati chande
Date:
Subject: Re: [Password?]
Next
From: Andres Freund
Date:
Subject: Re: SELECT DISTINCT very slow