Badrinath,
1.) A remark:
Why do you open new threads for the same question? Keeping it in an original therad is much less confusing for all of us.
2.) An answer to your question:
You have table A and table B. You want to delete all rows from table A where matching keys are found in table B. For any row in B (or at least for majority of them) there is a coresponding row in table A to be deleted. B is indexed on the comparising column. In this scenario, forget about using joins.
Basicaly you have two options.
a) The number of rows to be deleted from A is much less then the total number of rows in A (say you have 100.000.000 rows in A and you want to delete 50.000). In this case use:
DELETE FROM a WHERE a.col1 IN (SELECT b.col1 FROM b);
b) Almost all of the rows in A will be deleted (say you have 11.000.000 rows and 10.000.000 of them will be deleted). In this case use:
DELETE FROM a WHERE EXISTS (SELECT 1 FROM b WHERE a.col1 = b.col1);
HTH,
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?