Received: from ece.rice.edu (ece.rice.edu [128.42.4.34]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0TGdNl47366 for ; Tue, 29 Jan 2002 11:39:23 -0500 (EST) (envelope-from reedstrm@rice.edu) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with ESMTP id 84F0068A5A; Tue, 29 Jan 2002 10:39:28 -0600 (CST) Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154]) by ece.rice.edu (Postfix) with ESMTP id B697A68A57; Tue, 29 Jan 2002 10:39:27 -0600 (CST) Received: from reedstrm by wallace.ece.rice.edu with local (Exim 3.22 #1 (Debian)) id 16VbI7-0000Rp-00; Tue, 29 Jan 2002 10:39:27 -0600 Date: Tue, 29 Jan 2002 10:39:27 -0600 From: "Ross J. Reedstrom" To: "Zhang, Anna" Cc: pgsql-admin@postgresql.org Subject: Re: tuning SQL Message-ID: <20020129163927.GB1525@rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , "Zhang, Anna" , pgsql-admin@postgresql.org References: <5511D658682A7740BA295CCF1E1233A635A83F@vsvapostal2.bkup3> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5511D658682A7740BA295CCF1E1233A635A83F@vsvapostal2.bkup3> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS snapshot-20010714 X-Archive-Number: 200201/243 X-Sequence-Number: 3124 On Tue, Jan 29, 2002 at 10:57:01AM -0500, Zhang, Anna wrote: > Hi, > I am running a query on postgres 7.1.3 at Red Hat 7.2 (2 CPUs, 1.5G RAM, 2 > drive disk array). > select count(*) from contact a, contact_discard b where a.contacthandle <> > b.contacthandle; What are you trying to do with this query? As written, it'll give you a (roughly) cartesian product between the two tables. Here's a (small) example from one of my dbs: bioinfo=# select count(*) from people; count ------- 91 (1 row) bioinfo=# select count(*) from new_people; count ------- 70 (1 row) bioinfo=# select count(*) from people p, new_people n where p.peid=n.peid; count ------- 69 (1 row) bioinfo=# select count(*) from people p, new_people n where p.peid <> n.peid; count ------- 6301 (1 row) if what you want is the number of contacts not in contact_discard, that'd be something like: bioinfo=# select count(*) from people p where not exists (select peid from new_people where peid=p.peid); count ------- 22 (1 row) Ross -- Ross Reedstrom, Ph.D. reedstrm@rice.edu Executive Director phone: 713-348-6166 Gulf Coast Consortium for Bioinformatics fax: 713-348-6182 Rice University MS-39 Houston, TX 77005