function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ryanhcaryanhca 

Changing batch size

I haven't worked with the Apex Batch capabilities yet... it looks like the batch size is set to 200. However, some limits are lower than that -- such as the number of callouts allowed in a transaction (10). Is it possible to change the batch size to a lower number?

 

Basically, I need to run through all of the records of a particular object that meet the criteria, and for each, call an external web service (callout) and update the record accordingly.

 

And incidentally, it seems that the query/callout logic and the update logic would have to -- or could -- use different batch limits.

Best Answer chosen by Admin (Salesforce Developers) 
harryZharryZ

You can use the Database.executeBatch(sObject className, Integer scopeSize) method to set the batch size.

Be sure the scopeSize should less than 200.

All Answers

Anup JadhavAnup Jadhav

Hi ryancha,

 

The short answer to your question is 'no'. Salesforce chunks the records returned by the Database.QueryLocator into batches of 200, and then passes each batch to the executBatch method. I don't think that the user can control the batch size. 

 

Apex governer limis are reset for each execution of executeBatch() method.

 

You can find more details here:

http://www.salesforce.com/us/developer/docs/apexcode/index.htm 

 

Goto 'Batch Apex' -> 'Using Batch Apex'.

 

Hope this helps!

 

- A J

SGMSGM

Could you please tell me why in Appex Data Loader you could change the batch size?

 

Regards,

harryZharryZ

You can use the Database.executeBatch(sObject className, Integer scopeSize) method to set the batch size.

Be sure the scopeSize should less than 200.

This was selected as the best answer
jkucerajkucera

Thanks Harry!  

 

This is great for my campaign member batch process as everywhere in Salesforce the batch size for CM's is 100 except batch apex, which defaults to 200.  Now I can continue to use the effectively higher governor limits given batch size is 100 everywhere.

neao18neao18

Thanxs...it works......