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