View Single Post

   
  #1 (permalink)  
Old 02-27-2008, 07:56 AM
Odd Bjørn Andersen
 
Posts: n/a
Default Simple SQL question

I want to delete some rows from a table (TAB1), but only those rows which
has a match in antother table (TAB2). Something like this:

TAB1: col1, col2, .....
TAB2, col1, col2,......
There are indexes on col1 in both the tables.

The sql would be something like this

delete from tab1
where col1 in (select col1 from TAB2)

when I run this it takes 'for ever' to finish. I have tried to rewrite this
but cannot find a solution that runs fast.

There are 1.5 million rows in TAB1 and 50000 rows in TAB2. And , yes, i have
run runstats on both tables.

Anyone got a good solution to this?

Regards
Odd A


Reply With Quote