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
chesschess 

batch size for apex batch jobs

 I have a bunch of orders which i need to process. Since the procedure to process each order takes about 50 queries, I am passing these orders to the QueryLocator in an apex batch job with a batchsize of 1.

Does salesforce honor this batch size or is it merely a hint? I read somewhere that it is just a hint and SF could choose their own size to improve performance. That will not work for me since that would mean that SOQL limits could get violated - for instance if salesforce were to pick 5 orders in the batch.

 

 

KaranrajKaranraj

Did you try with batch size as 20.

Shashikant SharmaShashikant Sharma

Yes you can opt for any batch size 1, 5 or any number . By default it is 200 . About the limit is that in batch process limit are applied only with in a chunk of batch size, in next chunk it gets reset again.

 

Like you have 50 records to be processced in Batch and you have set batchsize equal to 5 then you will have 10 chunks to beprocessed  and after each chunk limit will be reset.  

 

To decide for batch size you have to decide it as per you businees logic that is there in execute method.