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
My OwnMy Own 

Reg: How to set batch size when using Batch Apex.

Hi All,


Is there any possibility of setting Apex Batch Size in Batch Apex. If so where would I have to specify that and is it possible to increase the batch size to more than 200. 


Thanks in Advance, 





i think we can do it in 2 ways , So far i have used only one approach , while executing your apex class we can pass an scope value , which defines the number of records per batch. batchclass cls = new batchclass(); Id batchid = Database.Execute(cls,1000); (min shuld be 1 , if we didnt declare it by default 200)

You can not give batch size more than 200.  Database.executeBatch method takes two parameters:


• The class that implements Database.Batchable.

• The number of records to be passed as a single chunk to the execute method. This value must be less than 200. Use this when you have many operations for each record being passed in and are running into governor limits.


For more information you can refer the Apex guide.


Hope this helps.

Abhik SahaAbhik Saha
As of now, I think you can set value from 1 to 2000 as scope size. But there is the concept of retrieve chunk and execute chunk.
Records from the query locator are retrieved in chunks of a given chunk size, called retrieveChunkSize. 

There are three available values for retrieveChunkSize: 100, 400, and 2000, and the smallest value that is greater than or equal to the scope size (scopeSize) will be chosen.
If 1 <= scopeSize <= 100, then retrieveChunkSize = 100
If 101 <= scopeSize <= 400, then retrieveChunkSize = 400
If 401 <= scopeSize <= 2000, then retrieveChunkSize = 2000
However, each execute chunk (that is the records passed to the execute() method) will have a size that will depend on the chosen retrieveChunkSize, the scopeSize, and the available records in the current retrieve chunk.
Refer to this link for detail -