sql - Oracle - delete based on join with two other tables -


i'm having little trouble designing code run fast.

my requirments are:

i have table scd(180mil records) , smaller table log(about 300 records).

log structure:

real_key | fic_key 

scd structure :

another_key | serial_key .... 

i need delete scd real key's, exists record fic_key, like

delete scd t serial_number in(select real_key log l1) , exists(select 1 scd s,log l2 s.serial_key = l2.fic_key            , l2.real_key = l1.real_key) 

the problem cant use first correlated query results compare second (l2.real_key = l1.real_key). also, if run, take lot of time since scd contains lot of records.

any appriciated.

first decide keys should deleted.

if want delete onlyreal_keys fic_key exist in scd, follows:

select real_key  log join scd on log.fic_key = scd.serial_key 

the delete than

delete scd serial_key in (  select real_key  log join scd on log.fic_key = scd.serial_key);  

if have index on serial_key in scd delete done 2 nl joins should quite instant. if no performance estimated 2 hash joins of scd table small table. should not ages 180m rows. may speed bit using parallel hash join.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -