Re: [SQL] comparing 2 tables. . .

Поиск
Список
Период
Сортировка
От Albert REINER
Тема Re: [SQL] comparing 2 tables. . .
Дата
Msg-id 19990924224748.A182@frithjof
обсуждение исходный текст
Ответ на RE: [SQL] comparing 2 tables. . .  (Stuart Rison <rison@biochemistry.ucl.ac.uk>)
Ответы Re: [SQL] comparing 2 tables. . .
Re: [SQL] comparing 2 tables. . .
Список 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 по дате отправления:

Предыдущее
От: Jose Pedro Aragao - LEI
Дата:
Сообщение: A question about triggers...
Следующее
От: Clayton Cottingham
Дата:
Сообщение: pg_dumpall + psql -e template1