I have an object that I need to delete the records nightly and then re-import. I am using a data maintenance batdch job to run the delete record trigger. My issue is it is taking a really long time to run through the records. I had a couple days in a row where the delete failed due to a timeout setting in shared properties. Now I have about 3 times as many records in that object as I should and it is overstating the data.
If I try to manually kick off the batch job, my browser hangs for 30-40 minutes before it says it was initiated and then it doesn't appear to be deleting any of the records.
This is the code I have inside the batch job.
Is there a better way to do this? Even when this was working early last week, it was taking a long time to process through the records.
Hello,
May I know the average number of records being deleted? Are there also "after delete" triggers running?
Thank you,
Gian
Nightly this should be around 55K records being deleted. That number should grow, but shouldn't be significantly higher than what it is now. Because of the failed batch, right now, there are 189K records that need to be removed.
There are no after delete triggers setup on this object.
Hello,
Let me find another way to do this. The way you are using it now is that it iterates thru all records and use the delete API to delete single record meaning on the 55k records, it runs 55k delete API triggers.
I'll let you know if I find anything.
Thank you,
Gian
Hello,
Also, please check if there are any orphan control record for your object because the object might also delete other related record which slows the deletion process.
Thank you,
Gian
Hello,
Thank you for the information you provided. Hmm.. It seems that this is the only way to delete all records using a batch job. I'll try to replicate this on my end and check the performance of the deletion process.
I'll let you know if I find anything else.
Thank you,
Gian
Hello,
After the process was "initiated" does it display anything in the system jobs section in the administration page? When you say last week, how long does it take to delete those records?
Thank you,
Gian
It doesn't say anything in the logs. I am unsure the exact time it took to complete. I had to manually run the batch job multiple times before it finished deleting all the records. It seemed to work for a while, but then would just stop like it had a timeout built in.
Hello,
It should run automatically on schedule though. Can you confirm this that the batch job is running? I don't see any problems with it deleting records if there are no triggers or orphan control in that object and even though it does time out, it should at least delete some records.
Let me know how it goes,
Thank you,
Gian
Yes, it does run nightly, but it can't get all the records done. Therefore, it is gradually increasing the number of records daily and is overstating the values, rendering the data useless.
Hello,
Please wait while I test this on my end. I will email you to get more information about this.
Thank you,
Gian
Hello,
Can you test this by creating a clone of the object and then run a manual batch job just to see if the performance is slow? Please test this while there are no other processes running in the system jobs. I just did a test on a newly created object and the deletion process only took minutes.
Thank you,
Gian