Just wanted to check the best option to delete the records from a table given a unique id (Delete * from Table where id=‘123’). One simplest way is writing a delete adapter service, nut not sure its advisable for mass deletion. Ex: I have a list of Unique Id’s, iterating over each records to delete.
Hi Niteesh,
Is it a one time activity to delete those 1000’s of records, or needs to be executed frequently on a daily basis? If it is few thousands of records that needs to be deleted during late ‘non-peak’ business hours or weekends, you can use custom sql instead of invoking delete adapter service ‘n’ times. However, if the data is huge in database, with constraints on the table, this delete would take more time and db might hung or respond very slow that time.
Thanks for the suggestion. Yes, its a daily file(But need not be 1000’s everyday). I have developed a java service which creates a string for the purpose of deletion using ‘IN’ statement Dynamic SQL(Ex: delete from table where id IN(‘id1’,‘id2’)).
This should be faster AFAIK, but let me know any bottlenecks of using this.
Hi Niteesh,
There are few restrictions like, the number of values in IN clause cannot cross more than 1000. Your java service based on the volume on that day, if it returns more than 1000, your processing will fail.
Instead of IN, you can use OR if it goes beyond 1000.
If your table has some date column, you can think of an alternative of using BETWEEN clause by passing range of dates. NOT IN is surely not advisable as it scans the entire table and has some known performance issue.
Probably, some database expert can advice on best way.
Yes, I am aware of IN restriction, and used OR. And process might slow,but still better than individual deletion i suppose. Since we are deleting records daily the record might not grow. Max it will be in few thousands(Less than 10,000 usually). And no, there is none other fields like date or range(Only ID’s). Lets see how it goes…