pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeffrey W. Baker <jwbaker@acm.org>
To: pgsql-performance@postgresql.org
Subject: Re: Index Usage using IN
Date: Wed, 01 Feb 2006 12:28:19 -0800
Message-ID: <1138825699.8376.8.camel@toonses.gghcwest.com> (raw)
In-Reply-To: <1138825370.8376.5.camel@toonses.gghcwest.com>
References: <43E1164B.7020104@telogis.com>
	<1138825370.8376.5.camel@toonses.gghcwest.com>

On Wed, 2006-02-01 at 12:22 -0800, Jeffrey W. Baker wrote:
> On Thu, 2006-02-02 at 09:12 +1300, Ralph Mason wrote:
> > Hi,
> > 
> > I have 2 tables both have an index on ID (both ID columns are an oid).
> > 
> > I want to find only only rows in one and not the other.
> > 
> > Select ID from TableA where ID not IN ( Select ID from Table B)
> 
> Have you considered this:
> 
> SELECT ID from TableA EXCEPT Select ID from Table B

Alternately:

   SELECT a.ID 
     FROM TableA AS a 
LEFT JOIN TableB AS b 
       ON a.ID = b.ID 
    WHERE b.ID IS NULL

-jwb



view thread (6+ messages)  latest in thread

Message-ID: <1138825699.8376.8.camel@toonses.gghcwest.com>
Permalink:  ../1138825699.8376.8.camel@toonses.gghcwest.com/
Also on:    postgresql.org/message-id/1138825699.8376.8.camel@toonses.gghcwest.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jwbaker@acm.org
  Subject: Re: Index Usage using IN
  In-Reply-To: <1138825699.8376.8.camel@toonses.gghcwest.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox