Re: DELETE using an outer join - Mailing list pgsql-sql

From Tom Lane
Subject Re: DELETE using an outer join
Date
Msg-id 21289.1342709554@sss.pgh.pa.us
Whole thread Raw
In response to DELETE using an outer join  (Thomas Kellerer <spam_eater@gmx.net>)
Responses Re: DELETE using an outer join
Re: DELETE using an outer join
List 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 by date:

Previous
From: Sergey Konoplev
Date:
Subject: Re: DELETE using an outer join
Next
From: Thomas Kellerer
Date:
Subject: Re: DELETE using an outer join