sql question for purge routine
Posted in 1997
hi,
we are doing a purge here on some huge tables, and this is the way
things are set up. we create a series of temp tables, and the final one has
two columns which are the values we are matching in the table we want to
delete from. this is the query that we are using:
select a.* from tab_to_purge a, tmp_table b
where a.col1 = b.col1
and a.col2 = b.col2
there are indexes on the temp table with update stats run after the
table and index are created. the index is a composite index on col1, col2.
this works great for some tables, but not for others, as they don't have the
proper indexes to make use of this, and we have space and time problems.
this doesn't seem like the best way to do this query, but i can't
see anything else. the other problem is, what about the delete? how do i
structure the delete in this case, as i can't say:
delete from tab_to_purge a, tmp_table b
where a.col1 = b.col1
and a.col2 = b.col2
so how do i handle the deletes?
delete from tab_to purge
where col1 in (select col1 from tmp_table)
and col2 in (select col2 form tmp_tabe)
doesn't seem like it will cut it. there are 330,000 rows in the temp table.
any help, suggestions, hints??
thanks,
mickm
--
_____________________________________________________________________________
Mickey Mestel mickm@netcom.com
-on a beach in thailand to a beautiful, stoned, norwegian woman:
"..yeah, it's just another foreign country without ice."
-----------------------------------------------------------------------------