Deleting rows using key from a 2nd table
Date: 1995/08/18
Message-ID: <412p06$7fs_at_ixnews7.ix.netcom.com>#1/1
I have a job where there's a very large table, and I want to delete a small number rows out of it based on data obtained from a much smaller table. I would normally using something like this...
DELETE FROM big_table a WHERE EXISTS
a.pkcol_2 = b.pkcol_2
(SELECT 'x' FROM small_table b
WHERE a.pkcol_1 = b.pkcol_1 AND
By looking at the statement though, it looks like it's going to try and go through the entire big_table which may contain millions of rows. Since the small table will only contain about 50,000 rows, of which only maybe 100 will exist in big_table and actually get deleted, isn't there a better way? Would using "IN" instead of "EXISTS" work better in this case? I've never seen a case where it did. How would you even use "IN" when there's more than one column involved?
TIA Please respond via email if possible.
-- Chuck Hamilton chuckh_at_ix.netcom.com Never share a foxhole with anyone braver than yourself!Received on Fri Aug 18 1995 - 00:00:00 CEST