Re: Correlated subqueries slow as hell?

From: Robin Parker <parkerr_at_logica.com>
Date: 1996/01/02
Message-ID: <parkerr.63.000F0E4E_at_logica.com>#1/1


>In article <jpanicoDKFAw0.Czw_at_netcom.com>, jpanico@netcom.com says...
>>
>>
>>My question has two parts:
>>
>>1) MYTABLE has an SSN and an ID column, among others. ID is unique,
>>SSN is not. If I want to see all the attributes for each row that
>>contains a *unique* SSN, and for those SSNs which have multiple rows
>>I don't care which row I see, how should I form the query? Is it possible
>>to form this query without using a correlated subquery, or must I
>>use something like:
>>
>>select * from MYTABLE T where T.ID = (select max(ID) from MYTABLE X
>> where X.SSN = T.SSN);
>>

You say that ID and SSN are indexed. Is that seperate indexes or just one. Are indexes Unique ? Seperate indexes should be OK. But single index SSN, ID would not be as good as single index ID, SSN (NON Unique).

Hope this is a help.

Robin Parker. Received on Tue Jan 02 1996 - 00:00:00 CET

Original text of this message