6

My previous question about slow Batches probably was to focused on a specific problem, so I try it again much broader.

What are general rules of thumb to make a slow Batch faster?

Although I added 2 of my own findings as answers, I want to invite others to contribute answers as well.

2 Answers 2

4

Get rid of implements Database.Stateful

Serializing and deserializing state (values of member variables in you Batch class) needs time and is performed for each single job (call of execute())

4

Use [Object].field = value instead of SObject.get() / SObject.put() .

This was mentioned by Salesforce.com support when we asked them why Batch code was so slow. We read and set arbitrary SObject fields we do not know in advance. So we had to resort to the generic functions. This caused a serious slow-down.

1
  • One approach to combine the generic flexibility and the speed of specific field assignments is to generate the assignment code during runtime. This is generally possible with something like the Metadata API (github.com/financialforcedev/apex-mdapi) Dec 9, 2014 at 8:31

You must log in to answer this question.

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