Hi, I am trying to delete rows from one table based on another table. The table from where I want to delete rows has about 200 million records and is growing everyday. This is a customer dimension mart which tracks changes on customer attributes. As part of the ETL process, I am deleting changed (current) records and appending changed& new records. The whole process is quick except for the deletion process as its my query which I believe may not be optimized. I do this currently : proc sql; delete * from customer_history where (select distinct customerno from x) and current_flag='Y'; Delete process takes more than 2 hours which defeats the purpose. X has about 800,000 to 1 million customerno generally. X is indexed on customerno. History table is indexed on customer, current_flag and a composite one having both.History has about 200m records. I understand the process I run currently has to traverse through all 200m records and apply the filter as part of the delete process. I can probably modify the ETL a bit to do this differently but before I do that I want to see if I am doing anything fundamentally wrong here? Any help is much appreciated. Thanks.
... View more