Re: Query brings system dowh, needs help
From: Adam Hoffman <hoffma_at_rpi.edu>
Date: 6 Mar 1995 15:23:09 GMT
Message-ID: <3jf9ct$fqh_at_usenet.rpi.edu>
Date: 6 Mar 1995 15:23:09 GMT
Message-ID: <3jf9ct$fqh_at_usenet.rpi.edu>
In article <3j1osf$95b_at_access1.digex.net>, gmisrod_at_access.digex.net (gmisassoc) says:
>
>
>I have two tables and I am running the following query:
>
>SELECT id FROM table1 WHERE id NOT IN
>(SELECT id FROM table2)
>
>Both tables are about 20,000 records each. This query is
>bringing a Sequent to its knees.
>
>What I want are all the ids that are in table1 but are not in table2.
>
>Any help is appreciated.
>
>Please respond to
>
Try using a NOT EXISTS clause such as:
select id from table1
where not exists (select 'x'
from table2 where table1.id = table2.id)
This will be especially efficient with indexes on the is columns. Received on Mon Mar 06 1995 - 16:23:09 CET