Re: [SQL] comparing 2 tables. . .

From: "Albert REINER" <areiner(at)tph(dot)tuwien(dot)ac(dot)at>
To: "'pgsql-sql(at)hub(dot)org'" <pgsql-sql(at)hub(dot)org>
Subject: Re: [SQL] comparing 2 tables. . .
Date: 1999-09-24 20:47:49
Message-ID: 19990924224748.A182@frithjof
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)tph(dot)tuwien(dot)ac(dot)at>
---------------------------------------------------------------------------

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jose Pedro Aragao - LEI 1999-09-24 21:34:14 A question about triggers...
Previous Message Chris Griffin 1999-09-24 15:39:13 Creating rules