Re: SELECT DISTINCT too slow - Mailing list pgsql-sql

From Tom Lane
Subject Re: SELECT DISTINCT too slow
Date
Msg-id 12554.1149175230@sss.pgh.pa.us
Whole thread Raw
In response to SELECT DISTINCT too slow  (Miroslav Šulc <miroslav.sulc@startnet.cz>)
Responses Re: SELECT DISTINCT too slow
List pgsql-sql
Miroslav Šulc <miroslav.sulc@startnet.cz> writes:
> I have a table with cca 400,000 rows. The table contains column "key" of
> varchar(20) type containing 10 distinct values. I want to get out what
> distinct values are present in the column. I use this simple query,
> which is very slow:

> SELECT DISTINCT Key FROM MRTPContactValue

TrySELECT Key FROM MRTPContactValue GROUP BY Key

The "select distinct" code is a bit old and crufty, GROUP BY is usually
smarter.
        regards, tom lane


pgsql-sql by date:

Previous
From: Miroslav Šulc
Date:
Subject: Re: SELECT DISTINCT too slow
Next
From: Miroslav Šulc
Date:
Subject: Re: SELECT DISTINCT too slow