Re: DELETE using an outer join

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: DELETE using an outer join
Дата
Msg-id 21289.1342709554@sss.pgh.pa.us
обсуждение исходный текст
Ответ на DELETE using an outer join  (Thomas Kellerer <spam_eater@gmx.net>)
Ответы Re: DELETE using an outer join  (Thomas Kellerer <spam_eater@gmx.net>)
Re: DELETE using an outer join  (Sergey Konoplev <gray.ru@gmail.com>)
Список pgsql-sql
Thomas Kellerer <spam_eater@gmx.net> writes:
> Lately I had some queries of the form:

>     select t.*
>     from some_table t
>     where t.id not in (select some_id from some_other_table);

> I could improve the performance of them drastically by changing the NOT NULL into an outer join:

>     select t.*
>     from some_table t
>        left join some_other_table ot on ot.id = t.id
>     where ot.id is null;

If you're using a reasonably recent version of PG, replacing the NOT IN
by a NOT EXISTS test should also help.

> Now I was wondering if a DELETE statement could be rewritten with the same "strategy":

Not at the moment.  There have been discussions of allowing the same
table name to be respecified in USING, but there are complications.
        regards, tom lane


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

Предыдущее
От: Sergey Konoplev
Дата:
Сообщение: Re: DELETE using an outer join
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: DELETE using an outer join