Re: Query brings system dowh, needs help
From: Doug Harris <ah513_at_FreeNet.Carleton.CA>
Date: Wed, 1 Mar 1995 22:18:24 GMT
Message-ID: <D4s8Mo.Hs1_at_freenet.carleton.ca>
Date: Wed, 1 Mar 1995 22:18:24 GMT
Message-ID: <D4s8Mo.Hs1_at_freenet.carleton.ca>
In a previous posting, gmisassoc (gmisrod_at_access.digex.net) writes:
> 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.
SELECT id FROM table1
MINUS
SELECT id FROM table2
Will often run faster. Make sure id is indexed and (if applicable) your CBO statistics are up to date.
-- - Doug Harris Database Administrator, System Development Division, Statistics Canada. ## WHERE ALL_OPINIONS.OWNER = USER ##Received on Wed Mar 01 1995 - 23:18:24 CET