Monday, October 17, 2011

Batch job performance boost

Did you ever have trouble with the performance of your batch-job? Well maybe this small trick can shorten the time your batch runs.
The big idea: Try to split up your gigantic batch in smaller pieces. Launch a batchjob that produces many smaller batchjobs (tasks) that can handle a subset of the data you need to process. For example you can create a batch that creates a batch with sub-tasks for each company.
How do you plan a batch from code?
1
2
3
4
5
6
7
8
9
10
11
12
BatchHeader batHeader;
BatchInfo batInfo;
TstRunBase rbbTask;
;
rbbTask = TstMyBatch::construct();
batInfo = rbbTask.batchInfo();
batInfo.parmCaption("MyBatch");
batInfo.parmGroupId("");
batHeader = BatchHeader::construct();
batHeader.addTask(rbbTask);
batHeader.save();
info(batInfo.parmCaption());
You can download a quick example I made. This is a job you can schedule and it will produce a new Batch job with a task for each company when you don’t select a company while shedualing (Class_TstRunBase.xpo). I hope this can help you.
Schedule the batch:

The result:

No comments:

Post a Comment