Subject Questions about SELECT DISTINCT *
Author robert_difalco
As you all know, a DISTINCT on many fields can be quite slow as it
needs to order unique all the fields in each row. This can get really
slow if there are large varchars in the result values.

Normally when I perform a SELECT DISTINCT * what I really mean is
SELECT DISTINCT uid.

Is there a standard SQL way to just designate just ONE of the result
values as DISTINCT rather than having them all be processed for
distinct handling? Maybe somehow using GROUP BY or some such?

Since I'm not very imaginative, the best I can think of is changing
something like:

SELECT DISTINCT * FROM Table [JOINS][WHERE];

To:

SELECT * FROM Table A WHERE A.uid IN
SELECT DISTINCT uid FROM Table [JOINS][WHERE];

Of course the only problem with this general pattern is that it wont
work if I'm creating the Join to add extra result values that are not
columns in "Table".

Thoughts?

R.