Re: Postgresql sql query - selecting rows outside a join

Поиск
Список
Период
Сортировка
От Adam Ruth
Тема Re: Postgresql sql query - selecting rows outside a join
Дата
Msg-id 8F83FCCA-2426-11D8-B2A5-000A959D1424@intercation.com
обсуждение исходный текст
Ответ на Postgresql sql query - selecting rows outside a join  (Graham Leggett <minfrin@sharp.fm>)
Список pgsql-general
On Dec 1, 2003, at 10:15 AM, Graham Leggett wrote:

> Hi all,
>
> I am trying to do a query that returns  all rows that are _not_ part of
> a join, and so far I cannot seem to find a query that doesn't take 30
> minutes or more to run.
>
> The basic query is "select * from tableA where tableA_id NOT IN (select
> tableA_id from tableB)".
>
> Is there a more efficient way of doing this?
>
> Regards,
> Graham
> --
>
This should be more efficient:

select * from tableA where not exists (select null from tableB where
tableA_id = tableA.tableA_id);

Version 7.4 fixes the slow IN - NOT IN, but I haven't tested it myself
yet to see how it compares to this.

Adam Ruth


В списке pgsql-general по дате отправления:

Предыдущее
От: "Rick Gigger"
Дата:
Сообщение: Re: Humor me: Postgresql vs. MySql (esp. licensing)
Следующее
От: "Roderick A. Anderson"
Дата:
Сообщение: Re: SRPM (PGDG) will not build