pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Albert REINER <areiner@tph.tuwien.ac.at>
To: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
Subject: Re: [SQL] comparing 2 tables. . .
Date: Fri, 24 Sep 1999 22:47:49 +0200
Message-ID: <19990924224748.A182@frithjof> (raw)
In-Reply-To: <Pine.LNX.4.10.9909241525440.26357-100000@bsmlx17>
References: <01BF06A4.7FFF3C60@Dan>
	<Pine.LNX.4.10.9909241525440.26357-100000@bsmlx17>

On Fri, Sep 24, 1999 at 03:32:51PM +0100, Stuart Rison wrote:
...
> Try:
> 
> SELECT tab1.pkey FROM <your_table> tab1 WHERE tab1.pkey NOT IN (SELECT
> tab2.pkey FROM <your_other_table> tab2.pkey);
> 
> or else (faster):
> 
> SELECT tab1.pkey FROM <your_table> tab1 WHERE NOT EXISTS (SELECT 1 FROM
> <your_other_table> tab2 WHERE tab1.pkey=tab2.pkey);

Maybe this is trivial, but...

Is there a simple way to see that/why the last query is faster?

Albert.

-- 

---------------------------------------------------------------------------
  Post an / Mail to / Skribu al: Albert Reiner <areiner@tph.tuwien.ac.at>
---------------------------------------------------------------------------



view thread (14+ messages)  latest in thread

Message-ID: <19990924224748.A182@frithjof>
Permalink:  ../19990924224748.A182@frithjof/
Also on:    postgresql.org/message-id/19990924224748.A182@frithjof

 · 

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-sql@postgresql.org
  Cc: areiner@tph.tuwien.ac.at, pgsql-sql@hub.org
  Subject: Re: [SQL] comparing 2 tables. . .
  In-Reply-To: <19990924224748.A182@frithjof>

* 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