Re: [SQL] comparing 2 tables. . . - Mailing list pgsql-sql

From Albert REINER
Subject Re: [SQL] comparing 2 tables. . .
Date
Msg-id 19990924224748.A182@frithjof
Whole thread Raw
In response to RE: [SQL] comparing 2 tables. . .  (Stuart Rison <rison@biochemistry.ucl.ac.uk>)
Responses Re: [SQL] comparing 2 tables. . .
Re: [SQL] comparing 2 tables. . .
List pgsql-sql
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>
 
---------------------------------------------------------------------------


pgsql-sql by date:

Previous
From: Jose Pedro Aragao - LEI
Date:
Subject: A question about triggers...
Next
From: Clayton Cottingham
Date:
Subject: pg_dumpall + psql -e template1