[SQL] DELETE using an outer join

2012-07-19 Thread Thomas Kellerer
Hi, (this is not a real world problem, just something I'm playing around with). 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

Re: [SQL] DELETE using an outer join

2012-07-19 Thread Sergey Konoplev
On Thu, Jul 19, 2012 at 4:43 PM, Thomas Kellerer spam_ea...@gmx.net wrote: delete from some_table where id not in (select min(id) from some_table group by col1, col2 having count(*) 1); (It's the usual - at least for me -

Re: [SQL] DELETE using an outer join

2012-07-19 Thread Tom Lane
Thomas Kellerer spam_ea...@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: