1

I scheduled a batch apex class to delete around 350,000 records on Friday evening, the process has been running over the weekend and this morning it's still on the batch 416 out of 1668, is it normal for batch apex to take such a long time?. There are no dependencies on this deletion but I am curious as to why it's taking so long. Perhaps, it's because I didn't specify a batch size and it's running on the default batch size?

public void QueueCleaner(){

String query = 'SELECT id FROM Case WHERE OwnerId = \'00G50000001Pdd2EAC\'';

            BatchJunkDelete batchApex = new BatchJunkDelete(query );
            ID batchprocessid = Database.executeBatch(batchApex);


            }
  • Avoid using inner query to increase batch performance – J_B Oct 8 '12 at 18:00
  • Can you add the code you're using for this batch Apex job? Primarily the SOQL query you're using to base it off of. This will help us rule out any crazy performance issues on you end. – JLiljegren__c Oct 8 '12 at 19:38
3

Basically its an async job .Asynchronous apex executes when resources get available in the salesforce servers so its normal that sometimes it takes time .

There can be one more reason is your code .If its not optimised it may take time .

Also if it was only for simply deleting using bulk API or data loader enabled with bulk API would have processed your job quicker.

  • Thanks Mohith. I want to do this through Apex because I want the process to run automatically every certain days without having to run it from a computer e.g. Data Loader CLI. In fact, only the first time I would need to delete such a large amount of records and probably I wouldn't need to use batch apex for this and just do it through DL the first time. I was just wondering if it normally takes so long as it's the first time I do something like this using apex. – PepeFloyd Oct 8 '12 at 10:59
1

Worth checking in the Setup > Monitoing > Apex Jobs - checks if you can see instances of your regularly updating . Check the LastModiiedDate to see when the last update was. If it hasn't progressed you might have to abort and restart.

A whole weekend for 350K records doesn't sound right unless there is some crazy complex processing.

The default batch size is 200, so you should be alright.

  • Thanks. The code doesn't have any complex logic, basically I am just deleting some cases. 20 minutes after I created the post it has progressed 2 batches (around 400 records ). – PepeFloyd Oct 8 '12 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.