I want to delete thousands of cases in my org preferably 25k at a time.

I have written a batch class for this. However during testing i found that its taking 30 minutes to delete 500 cases through batch job.

Then i switched to using data loader for the same job. Here also the time taken to delete cases remained the same.

After checking everything it seems for deleting each case recalculation of sharing rules/case sharing rules is triggered which takes up most of the time.

However this rate is not feasible to me as i need to delete 1 Million cases from my org without reducing the overall performance of the appilcation.

Is there anyway I could speed up the deletion of cases?

Any help regarding this will be hugely appreciated.

1 Answer 1


It is possible to defer sharing rule calculations, which might help if you are fairly certain sharing recalculation is the root cause.

Take a look at Deferring Sharing Rule Calculations. Unfortunately:

The defer sharing calculation feature isn't enabled by default. To enable it for your organization, contact Salesforce.

So here are the steps you need to take to implement:

  1. Contact Salesforce to enable the defer sharing calculation feature.
  2. Once it is enabled, from Setup, enter Defer Sharing Calculations in the Quick Find box, then select Defer Sharing Calculations.
  3. In the Sharing Rule Calculations related list, click Suspend.
  4. Run batch to delete records.
  5. In the Sharing Rule Calculations related list, click Resume.
  • Deferring sharing rule calculations may delete the cases quickly but these calculations will happen some time in future which puts at risk the application performance considering the huge data we have. Jun 11, 2016 at 17:22
  • You should be able to rerun the calculations after you hit Resume. I'm not sure there are any other steps you can take... @maniac
    – Adrian Larson
    Jun 11, 2016 at 17:23
  • Is Asynchronous Parallel Recalculation of Sharing Rules different to Defer Sharing Calculations? developer.salesforce.com/docs/… Jun 13, 2016 at 11:03
  • @Andy I don't think so. That feature cannot be manually activated, and there are only three use cases listed in that document where it is activated by the system.
    – Adrian Larson
    Jun 14, 2016 at 15:28
  • 1
    The defer sharing rules method actually speeds up the deletion of cases by more than 60%. But it comes at a 'suicide' price i.e, total lockdown of organisation for most of the normal work. I deleted 2500 cases and it took around 6 hours for sharing rules to recalculate. During that you cannot change anything and if any record is created which has sharing criteria, it will not work and create further mess of the entire org. This step is not at all desirable as it creates a lot of problem instead of solving. Jun 25, 2016 at 7:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .