Re: [SQL] comparing 2 tables. . .

Поиск
Список
Период
Сортировка
Искать
От
Stuart Rison
Тема
Re: [SQL] comparing 2 tables. . .
Дата
Msg-id
Pine.LNX.4.10.9909271153130.28372-100000@bsmlx17
Ответ на
Список
Дерево обсуждения
RE: [SQL] comparing 2 tables. . . Daniel Péder <dpeder@infoset.cz>
RE: [SQL] comparing 2 tables. . . Stuart Rison <rison@biochemistry.ucl.ac.uk>
Re: [SQL] comparing 2 tables. . . "Albert REINER" <areiner@tph.tuwien.ac.at>
Re: [SQL] comparing 2 tables. . . Engard Ferenc <fery@pons.sote.hu>
Re: [SQL] comparing 2 tables. . . Stuart Rison <rison@biochemistry.ucl.ac.uk>
Well, I guess officially you're supposed to be able to decode an EXPLAIN
of each statement but I'm not quite that savvy (yet).

With regards to this specific examples, I seem to remember a number of
previous postings that say that (NOT) EXISTS type statements are much
faster that (NOT) IN (SELECT...) type statements (because that kind of
sub-select is currently sub-optimally implemented in PG).

regards,

Stuart.

On Fri, 24 Sep 1999, Albert REINER wrote:

> On Fri, Sep 24, 1999 at 03:32:51PM +0100, Stuart Rison wrote:
> ...
> > Try:
> > 
> > SELECT tab1.pkey FROM  tab1 WHERE tab1.pkey NOT IN (SELECT
> > tab2.pkey FROM  tab2.pkey);
> > 
> > or else (faster):
> > 
> > SELECT tab1.pkey FROM  tab1 WHERE NOT EXISTS (SELECT 1 FROM
> >  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 
> ---------------------------------------------------------------------------
> 
> ************
> 

Stuart C. G. Rison
Department of Biochemistry and Molecular Biology
6th floor, Darwin Building, University College London (UCL)
Gower Street, London, WC1E 6BT, United Kingdom
Tel. 0207 504 2303, Fax. 0207 380 7033
e-mail: rison@biochem.ucl.ac.uk


В списке pgsql-sql по дате отправления
От: Dipankar Chakrabarti
Дата:
Сообщение: Re: "order by" weirdness
От: Tom Lane
Дата:
FAQ