X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 679889DC816 for ; Tue, 14 Feb 2006 17:24:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70134-01 for ; Tue, 14 Feb 2006 17:24:19 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [216.148.227.153]) by postgresql.org (Postfix) with ESMTP id 10B489DC859 for ; Tue, 14 Feb 2006 17:24:15 -0400 (AST) Received: from [10.0.1.5] (c-24-20-199-254.hsd1.or.comcast.net[24.20.199.254]) by comcast.net (rwcrmhc13) with SMTP id <20060214212417m1300fio7ae>; Tue, 14 Feb 2006 21:24:17 +0000 Subject: Re: Non Matching Records in Two Tables From: Ken Hill Reply-To: ken@scottshill.com To: chester c young Cc: pgsql-sql@postgresql.org In-Reply-To: <20060214210829.79695.qmail@web54302.mail.yahoo.com> References: <20060214210829.79695.qmail@web54302.mail.yahoo.com> Content-Type: multipart/alternative; boundary="=-6wbF/50cwR65Sh0tTIfZ" Organization: Scotts Hill Associates, Inc. Date: Tue, 14 Feb 2006 13:24:54 -0800 Message-Id: <1139952295.3083.67.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.078 required=5 tests=[AWL=0.077, HTML_MESSAGE=0.001] X-Spam-Score: 0.078 X-Spam-Level: X-Archive-Number: 200602/155 X-Sequence-Number: 24165 --=-6wbF/50cwR65Sh0tTIfZ Content-Type: text/plain Content-Transfer-Encoding: 7bit On Tue, 2006-02-14 at 13:08 -0800, chester c young wrote: > > Here is my query SQL: > > > > SELECT key100 FROM ncccr10 > > WHERE ncccr10.key100 NOT IN (SELECT key100 FROM ncccr9); > > > > It is is running after 30 minutes. Here is the query plan: > > > > I would try an outer join: > > select a.key100 > from ncccr10 a > left join ncccr9 b on( key100 ) > where b.key100 is null; > > also (hate to be obvious) have you analyzed lately? > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly Yes, I did a VACUUM ANALYZE on the entire database before running this query. Also, I get an error with your suggestion: csalgorithm=# SELECT a.key100 FROM ncccr10 a csalgorithm-# LEFT JOIN ncccr9 b ON(a.key100) csalgorithm-# WHERE b.key100 IS Null; ERROR: argument of JOIN/ON must be type boolean, not type character --=-6wbF/50cwR65Sh0tTIfZ Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit On Tue, 2006-02-14 at 13:08 -0800, chester c young wrote:
> Here is my query SQL:
> 
> SELECT key100 FROM ncccr10
> WHERE ncccr10.key100 NOT IN (SELECT key100 FROM ncccr9);
> 
> It is is running after 30 minutes. Here is the query plan:
>

I would try an outer join:

select a.key100
from ncccr10 a
left join ncccr9 b on( key100 )
where b.key100 is null;

also (hate to be obvious) have you analyzed lately?


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly
Yes, I did a VACUUM ANALYZE on the entire database before running this query. Also, I get an error with your suggestion:

csalgorithm=# SELECT a.key100 FROM ncccr10 a
csalgorithm-# LEFT JOIN ncccr9 b ON(a.key100)
csalgorithm-# WHERE b.key100 IS Null;
ERROR:  argument of JOIN/ON must be type boolean, not type character

--=-6wbF/50cwR65Sh0tTIfZ--